mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]>
Cc: Paul Gortmaker <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: viresh kumar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
7041717e7c
commit
e47c6a3408
1 changed files with 3 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue