From patchwork Mon Jan 5 09:52:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5566181 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1E435BF6C3 for ; Mon, 5 Jan 2015 09:52:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BB3420165 for ; Mon, 5 Jan 2015 09:52:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 169D920166 for ; Mon, 5 Jan 2015 09:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753263AbbAEJwu (ORCPT ); Mon, 5 Jan 2015 04:52:50 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:34679 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752923AbbAEJwt (ORCPT ); Mon, 5 Jan 2015 04:52:49 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NHP00EO57MPX170@mailout4.w1.samsung.com>; Mon, 05 Jan 2015 09:56:49 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-09-54aa5eefdec3 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id BE.14.07834.FEE5AA45; Mon, 05 Jan 2015 09:52:47 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NHP005IF7FVHQ30@eusync2.samsung.com>; Mon, 05 Jan 2015 09:52:47 +0000 (GMT) From: Krzysztof Kozlowski To: Mike Turquette , Stephen Boyd , Sylwester Nawrocki , Tomasz Figa , Kukjin Kim , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH 2/2] clk: exynos-audss: Fix memory leak on driver unbind or probe failure Date: Mon, 05 Jan 2015 10:52:41 +0100 Message-id: <1420451561-12360-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1420451561-12360-1-git-send-email-k.kozlowski@samsung.com> References: <1420451561-12360-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgluLIzCtJLcpLzFFi42I5/e/4Fd33catCDI480rZ4/cLQov/xa2aL TY+vsVpc3jWHzWLG+X1MFk8nXGSzOPymndXix5luFotVu/4wOnB6XO7rZfLYOesuu8emVZ1s Hneu7WHz2Lyk3qNvyypGj8+b5ALYo7hsUlJzMstSi/TtErgyDvzawFJwS6CisX8BWwPjJ94u Rk4OCQETidu3N7BB2GISF+6tB7K5OIQEljJKzJ7+nBXC6WOS2PDgMStIFZuAscTm5UvAqkQE NjJJ9OxbwA6SYBYwlPj57g+YLSwQLbGq/z9YA4uAqsTUBT/B4rwC7hJ/9ryBWicncfLYZLAa TgEPid0/XgPVcABtc5f4OFFzAiPvAkaGVYyiqaXJBcVJ6bmGesWJucWleel6yfm5mxghofdl B+PiY1aHGAU4GJV4eD1OrAwRYk0sK67MPcQowcGsJMK77hZQiDclsbIqtSg/vqg0J7X4ECMT B6dUA6O5mG30AYXc+dNmNzKcYvgqKHFqiqbu4e3br7lknDDMSVt5+2LZrfuvdr2siJTtbk5f w9b2isv1qfOzsjjDBvfyqb+Crf5sndg+OdVx19o9TYcW3bxhzTztjaCM3/qXNbHrmmumrNzE Hn7ffbuN3i+OnSFud9OKTTkj1m6/e8Y9fd0VbjX7GDYlluKMREMt5qLiRABV3kZaGwIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 The memory allocated by basic clock divider/gate/mux (struct clk_gate, clk_divider and clk_mux) was leaking. During driver unbind or probe failure the driver only unregistered the clocks. Use clk_unregister_{gate,divider,mux} to release all resources. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Stephen Boyd --- drivers/clk/samsung/clk-exynos-audss.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos-audss.c b/drivers/clk/samsung/clk-exynos-audss.c index f2c2ccce49bb..454b02ae486a 100644 --- a/drivers/clk/samsung/clk-exynos-audss.c +++ b/drivers/clk/samsung/clk-exynos-audss.c @@ -82,6 +82,26 @@ static const struct of_device_id exynos_audss_clk_of_match[] = { {}, }; +static void exynos_audss_clk_teardown(void) +{ + int i; + + for (i = EXYNOS_MOUT_AUDSS; i < EXYNOS_DOUT_SRP; i++) { + if (!IS_ERR(clk_table[i])) + clk_unregister_mux(clk_table[i]); + } + + for (; i < EXYNOS_SRP_CLK; i++) { + if (!IS_ERR(clk_table[i])) + clk_unregister_divider(clk_table[i]); + } + + for (; i < clk_data.clk_num; i++) { + if (!IS_ERR(clk_table[i])) + clk_unregister_gate(clk_table[i]); + } +} + /* register exynos_audss clocks */ static int exynos_audss_clk_probe(struct platform_device *pdev) { @@ -219,10 +239,7 @@ static int exynos_audss_clk_probe(struct platform_device *pdev) return 0; unregister: - for (i = 0; i < clk_data.clk_num; i++) { - if (!IS_ERR(clk_table[i])) - clk_unregister(clk_table[i]); - } + exynos_audss_clk_teardown(); if (!IS_ERR(epll)) clk_disable_unprepare(epll); @@ -232,18 +249,13 @@ unregister: static int exynos_audss_clk_remove(struct platform_device *pdev) { - int i; - #ifdef CONFIG_PM_SLEEP unregister_syscore_ops(&exynos_audss_clk_syscore_ops); #endif of_clk_del_provider(pdev->dev.of_node); - for (i = 0; i < clk_data.clk_num; i++) { - if (!IS_ERR(clk_table[i])) - clk_unregister(clk_table[i]); - } + exynos_audss_clk_teardown(); if (!IS_ERR(epll)) clk_disable_unprepare(epll);