linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: David Binderman <dcb314@hotmail.com>
Cc: paulus@samba.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: arch/powerpc/kernel/cacheinfo.c: Possible null pointer dereference
Date: Mon, 14 Feb 2011 10:24:30 +1100	[thread overview]
Message-ID: <1297639470.9492.11.camel@concordia> (raw)
In-Reply-To: <BLU154-w1013E8541813DF8B7564CD9CEE0@phx.gbl>

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

On Sat, 2011-02-12 at 10:08 +0000, David Binderman wrote:
> Hello there,
> 
> I just tried out cppcheck-1.47 on the linux-2.6.38-rc4 source code.
> 
> It said
> 
> [arch/powerpc/kernel/cacheinfo.c:380]: (error) Possible null pointer
> dereference: cache - otherwise it is redundant to check if cache is
> null at line 382
> 
> The source code is
> 
>     WARN_ONCE(cache && cache->level != level,
>           "cache level mismatch on lookup (got %d, expected %d)\n",
>           cache->level, level);
> 
>     if (!cache)
> 
> I agree with cppcheck. Suggest code rework.

It's wrong.

The code is essentially:

if (cache && cache->level != level)
	printf("cache level mismatch on lookup (got %d, expected %d)\n", cache->level, level);

if (!cache)
	cache = cache_do_one_devnode(node, level);


Which looks fine to me?

cheers

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

      reply	other threads:[~2011-02-13 23:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-12 10:08 arch/powerpc/kernel/cacheinfo.c: Possible null pointer dereference David Binderman
2011-02-13 23:24 ` Michael Ellerman [this message]

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=1297639470.9492.11.camel@concordia \
    --to=michael@ellerman.id.au \
    --cc=dcb314@hotmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.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).