From: Paul Mundt <lethal@linux-sh.org>
To: linux-sh@vger.kernel.org
Subject: Re: [patch] sh: clkfwk: potential null deref in debug code
Date: Wed, 23 Mar 2011 13:32:31 +0000 [thread overview]
Message-ID: <20110323133231.GC17693@linux-sh.org> (raw)
In-Reply-To: <20110320111249.GH2008@bicker>
On Sun, Mar 20, 2011 at 04:57:50PM +0100, Guennadi Liakhovetski wrote:
> Hi Dan
>
> On Sun, 20 Mar 2011, Dan Carpenter wrote:
>
> > This function is designed to accept a NULL for "best_freq" but the
> > debug code dereferences it unconditionally.
> >
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > ---
> > Btw. Smatch complains that "best" could NULL as well, but I don't
> > know if actually that's possible so I left it as is.
> >
> > diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c
> > index 5f63c3b..dee971c 100644
> > --- a/drivers/sh/clk/core.c
> > +++ b/drivers/sh/clk/core.c
> > @@ -616,7 +616,7 @@ long clk_round_parent(struct clk *clk, unsigned long target,
> >
> > pr_debug("%u / %lu = %lu, / %lu = %lu, best %lu, parent %u\n",
> > freq->frequency, div, freq_high, div + 1, freq_low,
> > - *best_freq, best->frequency);
> > + best_freq ? *best_freq : -1, best->frequency);
>
> What about another occasion of dereferencing best_freq at the top of the
> clk_round_parent() function:
>
> if (!parent) {
> *parent_freq = 0;
> *best_freq = clk_round_rate(clk, target);
> return abs(target - *best_freq);
> }
>
> ?
>
Do we actually have users that are passing in NULL for best_freq? I don't
recall writing this code, so I assume you did :-)
next prev parent reply other threads:[~2011-03-23 13:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-20 11:12 [patch] sh: clkfwk: potential null deref in debug code Dan Carpenter
2011-03-20 15:57 ` Guennadi Liakhovetski
2011-03-23 13:32 ` Paul Mundt [this message]
2011-03-23 14:01 ` Guennadi Liakhovetski
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=20110323133231.GC17693@linux-sh.org \
--to=lethal@linux-sh.org \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).