From 20c66599d431e9263aed14be5d0e39e2f92025ec Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Sat, 21 Jul 2012 10:54:40 +1000 Subject: [PATCH] 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 Cc: Paul Gortmaker Cc: Viresh Kumar Cc: viresh kumar Signed-off-by: Andrew Morton --- drivers/clk/clk.c | 3 +++ 1 file changed, 3 insertions(+) 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) if (!clk) return; + if (WARN_ON(IS_ERR(clk))) + return; + if (WARN_ON(clk->enable_count == 0)) return; -- 2.39.5