[PATCH] clk: validate pointer in __clk_disable()
Andrew Morton
akpm at linux-foundation.org
Fri Jun 8 18:37:57 EDT 2012
(cc viresh kumar <viresh.linux at gmail.com>!)
On Thu, 7 Jun 2012 13:52:59 +0900
Fengguang Wu <fengguang.wu at intel.com> wrote:
> 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.
> ---
> drivers/clk/clk.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 687b00d..7bd795bf9 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -464,6 +464,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;
Fair enough.
But the build breakage reported by Paul remains, and the patchset
remains unmerged.
More information about the linux-arm-kernel
mailing list