linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: Correct handling of NULL clk in __clk_{get, put}
@ 2014-01-07 12:03 Sylwester Nawrocki
  2014-01-07 13:00 ` Lothar Waßmann
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Sylwester Nawrocki @ 2014-01-07 12:03 UTC (permalink / raw)
  To: linux-arm-kernel

Ensure clk->kref is dereferenced only when clk is not NULL.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
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(-)

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        ***/
--
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-02-25 17:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-07 12:03 [PATCH] clk: Correct handling of NULL clk in __clk_{get, put} Sylwester Nawrocki
2014-01-07 13:00 ` Lothar Waßmann
2014-01-07 13:14   ` Sylwester Nawrocki
2014-01-08  4:44 ` Sachin Kamat
2014-01-10 10:04   ` Sylwester Nawrocki
2014-01-30  4:50     ` Sachin Kamat
2014-02-10 15:02       ` Sylwester Nawrocki
2014-02-24 12:59         ` Tomasz Figa
2014-02-25  6:16 ` Mike Turquette
2014-02-25 17:34   ` Tomasz Figa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).