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: 3447301 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 4C2649F374 for ; Tue, 7 Jan 2014 12:04:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2FCEC20115 for ; Tue, 7 Jan 2014 12:04:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E43F2010C for ; Tue, 7 Jan 2014 12:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750904AbaAGMEU (ORCPT ); Tue, 7 Jan 2014 07:04:20 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:23436 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbaAGMET (ORCPT ); Tue, 7 Jan 2014 07:04:19 -0500 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-samsung-soc@vger.kernel.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 Cc: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mturquette@linaro.org, tomasz.figa@gmail.com, Sylwester Nawrocki 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 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, 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 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 ***/