From patchwork Sun Jun 13 05:29:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zpershuai X-Patchwork-Id: 12317299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C812C48BDF for ; Sun, 13 Jun 2021 05:29:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1419B61105 for ; Sun, 13 Jun 2021 05:29:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1419B61105 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=9Bj+jT26WYH0uYIWCVjRkAmQ8DJ6RQYq8II0LwSKYmU=; b=ibKM9tz5ylQDNm IrA/tyxCF4yuVc+zATeBe6QZjhRnLqKu9h7zc9pzti17Pud7vOOcIJ+PYzLYt7DIj5wAVGw/cFixt LOW30sCOjZLgn4idVliMsT2FKY1yFTRn2DSw0g11KFS1fQoFpTcMSjnhBMnZ/REOKxTAcBNGpeec+ 4picJMsLEjNag2bc+t4gP1SgydccjAqdiXfil79HfX1j0mYN0nU02+99bpTqzVIF02EuIa6yWW+8Q nt1V8drybWNu8Ee31CXUMKPBjzkHCzRWeNFSVNzJOiP4wzYtauE4oj+4saHiPaJXbihKvkqcjWKVc Op46AaI+IE/6oGoyucvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsIgi-009iFG-IM; Sun, 13 Jun 2021 05:29:36 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsIgW-009iED-Ve; Sun, 13 Jun 2021 05:29:26 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d16so7954471pfn.12; Sat, 12 Jun 2021 22:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6AdJa+7WrAfZXyHfw2qNyNJLE7yY0Qr/CD/Tk8b4dL4=; b=aja0+fMUKycQTU0t/8Wj2w4U4OqO3dy13LeMaGgx+O5RrfQri1eEWXHsQIsQbOQhKx osu/Czw415aFn1JzF218SG//xcAaa+LgL2Nyg3QGG0oCyZcZW4Ver/F8cYlYdaMJ6U8r zBWt4sX3CwnfozqTEiQhIguXf66D9iWlsI/Klu6CnS9zmdON18V/abhfUT5eciBNJDfI mL8vpOHRd2ic595qzIp/v52wRHbqV43dvRxuVh0PEBWJ/qC+QnEgQZpZfT+qNxUbmPog g8e7+7ZqzQwgIQGZsj+p8lkof4qamrv+aFcdQOf4iRJRAkzaxNiWNZ+Y41eO/TUif9wi 4rBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6AdJa+7WrAfZXyHfw2qNyNJLE7yY0Qr/CD/Tk8b4dL4=; b=aii4LThkEoeBl3pIyKu1CGZw5WGkOSTA4oKdzLyqaJrVkQ4aF8Mq885qz2y0Ik8ORs OBF0fvVK1euivYSGwO/DsaT1gGxD0mp32fidp/MDMOVu6HFPjaKary9omDju1fXIvrAH KK6ihO/Zw8pWbRCoEJHTQaMgkOEwBqfZIfowY7zvVTdQkkgnA/8lXmgKcn9il7Z4r/aP GK9iVZ4jnJRwj2N8MahiL1pG5VOTy2NirH4lKWKBy4kXdNXjupPIlG3E3hbTtNFnsDO3 S5RwaYt8UQBOdTl6i0zsgMiS2oIILBGW5uasaI0vfJ2abl/YrOGuEKdbzQm9Hib0xY0e BtCg== X-Gm-Message-State: AOAM532rLf2MrlZJkgNfXdJpsP6gaAbxh8f1D60rcdewjyG+wiaTD0SX SvnFGDFzT3mzgAtSsAwsDko= X-Google-Smtp-Source: ABdhPJzFeeQ2tdgUq7C9JKQ526BuE+bqLJ3Wdnj7gEMC6ZOwuUu/Mnc9icDaR2Ze5gpYzv82O8t1bw== X-Received: by 2002:aa7:808b:0:b029:2ef:cdd4:8297 with SMTP id v11-20020aa7808b0000b02902efcdd48297mr16032881pff.27.1623562162497; Sat, 12 Jun 2021 22:29:22 -0700 (PDT) Received: from localhost.members.linode.com ([2400:8902::f03c:92ff:fe55:8c1e]) by smtp.gmail.com with ESMTPSA id q68sm14397203pjq.45.2021.06.12.22.29.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Jun 2021 22:29:22 -0700 (PDT) From: zpershuai To: Mark Brown , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Cc: zpershuai Subject: [PATCH v2 1/2] spi: meson-spicc: fix memory leak in meson_spicc_probe Date: Sun, 13 Jun 2021 13:29:16 +0800 Message-Id: <1623562156-21995-1-git-send-email-zpershuai@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_222925_057173_DF897DCB X-CRM114-Status: GOOD ( 11.67 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org when meson_spicc_clk_init returns failed, it should goto the out_clk label. Signed-off-by: zpershuai Reviewed-by: Neil Armstrong --- drivers/spi/spi-meson-spicc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c index ecba6b4..d675334 100644 --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -752,7 +752,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ret = meson_spicc_clk_init(spicc); if (ret) { dev_err(&pdev->dev, "clock registration failed\n"); - goto out_master; + goto out_clk; } ret = devm_spi_register_master(&pdev->dev, master); From patchwork Sun Jun 13 05:29:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zpershuai X-Patchwork-Id: 12317301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB6B6C48BCF for ; Sun, 13 Jun 2021 05:30:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7254C611CE for ; Sun, 13 Jun 2021 05:30:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7254C611CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=EIZcxSck50HKoff1ikOWU/6yizZDjW0VFSZ5YTvW+MU=; b=FgTOV7qAXjCvyd yFcWnN5Co5y6FS5/sQ3YM72Y/2GG75A5mMCwipfdutMyasXZ2OAMV6PUje2BZ78SRWTyoRvStw5v2 N+iaiaQD75YnhwqvvqO6hkBTpF2YbWK86I62YOyteQ6sb9I+qa0Wf1dVB+1qV7eILbHw75Hy+dMR6 DK/WLNQfh2zbKzNt/EXSeEzAiEWiAA3vt8nEQWxeazxbOzItmNfqy5uQRnFhthD0btmKrmiu1E0um oxB+QEkBZgRC2oR/qJpCimQT5IBkRfC+LglB/O0P88yK0gqZ5JSK4lx7q+cwKKH8IQb9Gaq+FGbRL FrWMgjpO/lDAJXho6VbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsIhv-009iMb-FI; Sun, 13 Jun 2021 05:30:51 +0000 Received: from mail-pf1-f175.google.com ([209.85.210.175]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsIhi-009iKk-TS; Sun, 13 Jun 2021 05:30:40 +0000 Received: by mail-pf1-f175.google.com with SMTP id a127so2153201pfa.10; Sat, 12 Jun 2021 22:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=e9wgkbzyfzIDSr2mxBQKx6UIoHjiY2DxbVr5qjZ/ndQ=; b=vHJYnC5k2pNMcAka9+8PsEV+JyHpNrO1Q+mca4ikgwPyM7J8kx4lxeRPtqW9GZpK3Q whTSpSpNpB8Pk4/Gvp/A0pGwknW5N6z4PX4GwTt35nMnkbpbWJcqASxvvOV3LqelFXwX Yv4prjK1qW0UN21MJtRc1mV7KNYDfeK631XncDCWQKxz1GCQD2W5HS00NqV85nG2Lj/p twILRHztLdECx9SFbU1OZM+DLe37FoOKBW6qJKPe10t34PakAGF546XTAWkn5mb6T3DC gFz5/R3sIR2MaHwdxwJeoQRYChFeQkayEvgXePxTQcb/INfK9byZ+O3u/JqE2GXRNFbP 1HBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=e9wgkbzyfzIDSr2mxBQKx6UIoHjiY2DxbVr5qjZ/ndQ=; b=ME3HcW6XG43fMcLDktUbUtExCJDX0qbNo2sgvEaxcEYO9Ua5GpNLRJ7rIeS2FQcjQD Qw7UrqnaQmgimuwu24dNwxmkKteLRsbDXVpzbWGucWMImqfUYneY7AKbI6V5laM9IpJ7 RPH+8IVblTdPXOTJOqk9/fF2L9VWJrourz1d4A5n+KZpJXKzg1+D2GT2ZqNHbD2mwNC9 bs7Le+UoeI2CPjhTMMcP5Gezdwu838FqDFFZBTNc7jjQ/Ki992zmIe13VtdL2bn3gGqr kxkzevipBIZDZstmK65FaXN/bkzXotaGjjHxUG3yFDZH+viFx5Q5yD1TUFIgr02bv6wO 2G5w== X-Gm-Message-State: AOAM532LraWfqJZvpZy2Xz4/RTXXksk6SYETixSlQifEXmLe+A1V/bNe 8wae5RMBB9WWqYqXgkukMN0= X-Google-Smtp-Source: ABdhPJwa1Ill6bdxHT7ix4aev3b0DeJ4kB2NxTJRs3GR1xv0JqLnWXqYaOVRXpUeqq3RSx2rpNMaxw== X-Received: by 2002:a62:8491:0:b029:2e9:c618:fa32 with SMTP id k139-20020a6284910000b02902e9c618fa32mr15861684pfd.15.1623562178265; Sat, 12 Jun 2021 22:29:38 -0700 (PDT) Received: from localhost.members.linode.com ([2400:8902::f03c:92ff:fe55:8c1e]) by smtp.gmail.com with ESMTPSA id a9sm8810533pfo.69.2021.06.12.22.29.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Jun 2021 22:29:37 -0700 (PDT) From: zpershuai To: Mark Brown , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Cc: zpershuai Subject: [PATCH v2 2/2] spi: meson-spicc: fix a wrong goto jump for avoiding memory leak. Date: Sun, 13 Jun 2021 13:29:32 +0800 Message-Id: <1623562172-22056-1-git-send-email-zpershuai@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_223038_975259_F1E591C1 X-CRM114-Status: GOOD ( 10.85 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org In meson_spifc_probe function, when enable the device pclk clock is error, it should use clk_disable_unprepare to release the core clock. Signed-off-by: zpershuai Reviewed-by: Neil Armstrong --- drivers/spi/spi-meson-spicc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c index d675334..b2c4621 100644 --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -725,7 +725,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ret = clk_prepare_enable(spicc->pclk); if (ret) { dev_err(&pdev->dev, "pclk clock enable failed\n"); - goto out_master; + goto out_core_clk; } device_reset_optional(&pdev->dev); @@ -764,9 +764,11 @@ static int meson_spicc_probe(struct platform_device *pdev) return 0; out_clk: - clk_disable_unprepare(spicc->core); clk_disable_unprepare(spicc->pclk); +out_core_clk: + clk_disable_unprepare(spicc->core); + out_master: spi_master_put(master);