From patchwork Tue Jan 7 12:03:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 3447321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 32A399F374 for ; Tue, 7 Jan 2014 12:05:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 20D4820121 for ; Tue, 7 Jan 2014 12:05:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F16F720115 for ; Tue, 7 Jan 2014 12:04:59 +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 1W0VOu-00069L-6m; Tue, 07 Jan 2014 12:04:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0VOr-0004bD-LI; Tue, 07 Jan 2014 12:04:49 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0VOm-0004aG-SB for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2014 12:04:46 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MZ100KIK5J6W1A0@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2014 21:04:18 +0900 (KST) X-AuditID: cbfee61a-b7fb26d00000724f-be-52cbed422ee1 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 02.F1.29263.24DEBC25; Tue, 07 Jan 2014 21:04:18 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MZ100C1M5IXZQ30@mmp1.samsung.com>; Tue, 07 Jan 2014 21:04:18 +0900 (KST) From: Sylwester Nawrocki To: sachin.kamat@linaro.org Subject: [PATCH] clk: Correct handling of NULL clk in __clk_{get, put} Date: Tue, 07 Jan 2014 13:03:43 +0100 Message-id: <1389096223-23934-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGJMWRmVeSWpSXmKPExsVy+t9jAV2nt6eDDCb0CFpsenyN1WLG+X1M Fk8nXGSzOPymndXi5J9eRotVu/4wOrB57Jx1l93jzrU9bB6bl9R79G1ZxejxeZNcAGsUl01K ak5mWWqRvl0CV8byx/sZC25yVHzaNZmxgfETWxcjJ4eEgInE9enzWCFsMYkL99YDxbk4hAQW MUo0H1zOBOF0MEks/LcJrINNwFCi92gfI4gtIiAt8afhBjNIEbPAKkaJlvZJLCAJYQE3ia4Z /8AaWARUJSZO3cAOYvMCxV+9/w40lQNonYLEnEk2Exi5FzAyrGIUTS1ILihOSs811CtOzC0u zUvXS87P3cQIDo1nUjsYVzZYHGIU4GBU4uF9sfdUkBBrYllxZe4hRgkOZiURXuYbp4OEeFMS K6tSi/Lji0pzUosPMUpzsCiJ8x5otQ4UEkhPLEnNTk0tSC2CyTJxcEo1MG77oqEve1vs2TWx cNm9dtN/PrjDaKL7vCvwt/OeemeWvb4xU2vE12paJjpIRPhNL06f1RX97uEb2RqPkgss6/t0 Yq2Xv7wysUuL+SmbiEXKa2lm62vHPX5vyN+5hJuJvezd73fFiSXTrk2VjavyDT7Ovt10n6vp cV0ppkPupnEKjof/Ooa/U2Ipzkg01GIuKk4EABcuYbMJAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140107_070445_145612_C7C41F7A X-CRM114-Status: GOOD ( 10.33 ) X-Spam-Score: -6.9 (------) Cc: Sylwester Nawrocki , linux-samsung-soc@vger.kernel.org, mturquette@linaro.org, tomasz.figa@gmail.com, linux-arm-kernel@lists.infradead.org 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.2 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 Ensure clk->kref is dereferenced only when clk is not NULL. Signed-off-by: Sylwester Nawrocki Tested-by: Sachin Kamat --- Hi Sachin, please try if this patch fixes the exyno5420 boot crash. Thanks, Sylwester drivers/clk/clk.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 1.7.9.5 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index e3e0327..a1fe86f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2179,24 +2179,25 @@ EXPORT_SYMBOL_GPL(devm_clk_unregister); */ int __clk_get(struct clk *clk) { - if (clk && !try_module_get(clk->owner)) - return 0; + if (clk) { + if (!try_module_get(clk->owner)) + return 0; - kref_get(&clk->ref); + kref_get(&clk->ref); + } return 1; } void __clk_put(struct clk *clk) { - if (WARN_ON_ONCE(IS_ERR(clk))) + if (!clk || WARN_ON_ONCE(IS_ERR(clk))) return; clk_prepare_lock(); kref_put(&clk->ref, __clk_release); clk_prepare_unlock(); - if (clk) - module_put(clk->owner); + module_put(clk->owner); } /*** clk rate change notifiers ***/