From: akpm@linux-foundation•org (Andrew Morton)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH] clk: validate pointer in __clk_disable()
Date: Fri, 8 Jun 2012 15:37:57 -0700 [thread overview]
Message-ID: <20120608153757.8df63e6b.akpm@linux-foundation.org> (raw)
In-Reply-To: <20120607045259.GA16232@localhost>
(cc viresh kumar <viresh.linux@gmail•com>!)
On Thu, 7 Jun 2012 13:52:59 +0900
Fengguang Wu <fengguang.wu@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.
next prev parent reply other threads:[~2012-06-08 22:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120606214621.GA8892@localhost>
[not found] ` <20120606145113.f0c8ddcf.akpm@linux-foundation.org>
[not found] ` <20120606215951.GA9123@localhost>
[not found] ` <20120606150619.8567afb4.akpm@linux-foundation.org>
2012-06-06 22:42 ` Fwd: + clk-add-non-config_have_clk-routines.patch added to -mm tree Fengguang Wu
2012-06-06 22:49 ` Russell King - ARM Linux
2012-06-06 23:03 ` Fengguang Wu
2012-06-06 23:54 ` Russell King - ARM Linux
2012-06-07 4:52 ` [PATCH] clk: validate pointer in __clk_disable() Fengguang Wu
2012-06-08 22:37 ` Andrew Morton [this message]
2012-06-06 22:47 ` Fwd: + clk-add-non-config_have_clk-routines.patch added to -mm tree Fengguang Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120608153757.8df63e6b.akpm@linux-foundation.org \
--to=akpm@linux-foundation$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox