From patchwork Thu Oct 17 16:30:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3061971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0E488BF924 for ; Thu, 17 Oct 2013 16:34:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE84B2047C for ; Thu, 17 Oct 2013 16:34:23 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F4672039F for ; Thu, 17 Oct 2013 16:34:22 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWqVC-00080j-9h; Thu, 17 Oct 2013 16:32:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWqUj-0003IW-2k; Thu, 17 Oct 2013 16:32:17 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWqTz-0003BH-3R for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2013 16:31:33 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MUT009VUN7NN610@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2013 17:30:59 +0100 (BST) X-AuditID: cbfec7f4-b7f0a6d000007b1b-e7-526010c321c2 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 20.BD.31515.3C010625; Thu, 17 Oct 2013 17:30:59 +0100 (BST) Received: from amdc1227.digital.local ([106.116.147.199]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0MUT00F39N7B2000@eusync1.samsung.com>; Thu, 17 Oct 2013 17:30:59 +0100 (BST) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/8] clk: max77686: Fix clean-up in error and remove paths Date: Thu, 17 Oct 2013 18:30:39 +0200 Message-id: <1382027442-1992-6-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.8.3.2 In-reply-to: <1382027442-1992-1-git-send-email-t.figa@samsung.com> References: <1382027442-1992-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xy7qHBRKCDD5tMrWYf+Qcq8XZpjfs Fve/HmW02PT4GqvFjPP7mCyeTrjIZnG6m9Vi/YzXLA4cHneu7WHzmHcy0GPzknqPvi2rGD0+ b5ILYI3isklJzcksSy3St0vgynhyZClTwVqBinO3rrM2MO7l7WLk5JAQMJHYc/sVG4QtJnHh 3nogm4tDSGApo8T9vy2MEE4fk8TErS+YQarYBNQkPjc8AusQEdCQmNL1mB2kiFmghUli1frP TF2MHBzCAl4ST9+CmSwCqhLPf4WAlPMKOErcP3eMFWKZgsSyL2vBRnIKOEnMW3yLEcQWAqr5 2/qcaQIj7wJGhlWMoqmlyQXFSem5hnrFibnFpXnpesn5uZsYIYH1ZQfj4mNWhxgFOBiVeHgP fIsPEmJNLCuuzD3EKMHBrCTCG8eVECTEm5JYWZValB9fVJqTWnyIkYmDU6qBMX+e6q3QbUY/ 7H4tviP09h87o9ndbydvPVKeuShbyeezRa1iyq/1rv4+73Ycdr3x+PSCj2fXFXI09O/affDi v1WPmL7LOwnUnW8q3BIxj3n22ubyLE/BNdZ7rVLzKwL2nFPn8Pt7JSZ6y5Yt74653vtda2+z e6PS2t0db68fzxZT1byz9eHZKceVWIozEg21mIuKEwGZOARJCgIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131017_123131_323619_1E9966C4 X-CRM114-Status: UNSURE ( 9.41 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.3 (-------) Cc: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Mike Turquette , Samuel Ortiz , Tomasz Figa , Kyungmin Park , Lee Jones X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes invalid kfree() and adds missing call to clk_unregister() in error and remove paths in max77686_clk_probe(). While at it, error handling is also cleaned up. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- drivers/clk/clk-max77686.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 2e6ba0e..81b3680 100644 --- a/drivers/clk/clk-max77686.c +++ b/drivers/clk/clk-max77686.c @@ -162,20 +162,9 @@ static int max77686_clk_probe(struct platform_device *pdev) clk = max77686_clk_register(&pdev->dev, max77686_clks[i]); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - - switch (i) { - case MAX77686_CLK_AP: - dev_err(&pdev->dev, "Fail to register CLK_AP\n"); - goto err_clk_ap; - break; - case MAX77686_CLK_CP: - dev_err(&pdev->dev, "Fail to register CLK_CP\n"); - goto err_clk_cp; - break; - case MAX77686_CLK_PMIC: - dev_err(&pdev->dev, "Fail to register CLK_PMIC\n"); - goto err_clk_pmic; - } + dev_err(&pdev->dev, "failed to register %s\n", + max77686_clks[i]->hw.init->name); + goto err_clocks; } } @@ -183,13 +172,12 @@ static int max77686_clk_probe(struct platform_device *pdev) return 0; -err_clk_pmic: - clkdev_drop(max77686_clks[MAX77686_CLK_CP]->lookup); - kfree(max77686_clks[MAX77686_CLK_CP]->hw.clk); -err_clk_cp: - clkdev_drop(max77686_clks[MAX77686_CLK_AP]->lookup); - kfree(max77686_clks[MAX77686_CLK_AP]->hw.clk); -err_clk_ap: +err_clocks: + for (--i; i >= 0; --i) { + clkdev_drop(max77686_clks[i]->lookup); + clk_unregister(max77686_clks[i]->hw.clk); + } + return ret; } @@ -200,7 +188,7 @@ static int max77686_clk_remove(struct platform_device *pdev) for (i = 0; i < MAX77686_CLKS_NUM; i++) { clkdev_drop(max77686_clks[i]->lookup); - kfree(max77686_clks[i]->hw.clk); + clk_unregister(max77686_clks[i]->hw.clk); } return 0; }