aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorFengguang Wu <fengguang.wu@intel.com>2012-07-30 17:39:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:13 -0400
commite47c6a3408ea6bcfc5204f23d5a5b209de6e68b9 (patch)
tree0f515a18546fb2875a46d5cead87cb90e1401e38 /drivers/clk/clk.c
parent7041717e7c6ca33310d0c7333d9f7cebc65b2534 (diff)
clk: validate pointer in __clk_disable()
clk_get() returns -ENOENT on error and some careless caller might dereference it without error checking: In mxc_rnga_remove(): struct clk *clk = clk_get(&pdev->dev, "rng"); // ... clk_disable(clk); Since it's insane to audit the lots of existing and future clk users, let's add a check in the callee to avoid kernel panic and warn about any buggy user. Cc: Russell King <rmk@arm.linux.org.uk> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Viresh Kumar <viresh.kumar@st.com> Cc: viresh kumar <viresh.linux@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index c87fdd710560..efdfd009c270 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -465,6 +465,9 @@ static void __clk_disable(struct clk *clk)
465 if (!clk) 465 if (!clk)
466 return; 466 return;
467 467
468 if (WARN_ON(IS_ERR(clk)))
469 return;
470
468 if (WARN_ON(clk->enable_count == 0)) 471 if (WARN_ON(clk->enable_count == 0))
469 return; 472 return;
470 473