All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Peter Huewe <peterhuewe@gmx.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Joe Perches <joe@perches.com>,
	"Robert P. J. Day" <rpjday@crashcourse.ca>
Subject: Re: [PATCH 1/2] staging/sep: Fix smatch false positive about potential NULL dereference in sep_main.c
Date: Tue, 19 Feb 2013 15:25:08 +0300	[thread overview]
Message-ID: <20130219122508.GA9138@mwanda> (raw)
In-Reply-To: <1361275648-6259-1-git-send-email-peterhuewe@gmx.de>

On Tue, Feb 19, 2013 at 01:07:27PM +0100, Peter Huewe wrote:
> Smatch complains about a potential NULL pointer dereference:
> 
> sep_main.c:2312 sep_construct_dma_tables_from_lli() error: potential
> NULL dereference 'info_out_entry_ptr'.
> 
> info_out_entry_ptr is initialized with NULL and if info_in_entry_ptr is
> not NULL it gets derefenced.
> However info_out_entry_ptr is only NULL in the first iteration of the
> while loop and in this case info_in_entry_ptr is also NULL (as indicated
> by the comment /* If info entry is null - this is the first table built */
> -> this is a false positive.
> 
> Nevertheless we add a check for info_out_entry_ptr to silence this
> warning and make it more robust in regard to code changes.
> 

Smatch doesn't handle loops very well.  Of course, all along I've
wanted to fix this, but it's a bit complicated so it could be
another year or two before it actually happens.

Generally, as a philosophy, I always say never to change the code
for false positives.  It should be Smatch which changes.

Also the other thing is that with Smatch I deliberately allow more
false positives than GCC does.  It's a trade off between being
ambitious in looking for bugs and being annoying to users.

When Smatch looks at this code it sees the else side as impossible
to reach.  Perhaps I should add a hack in that if the code is in an
impossible to reach place then don't print a warning...  It would
be better to just fix loop handling...  I'm not sure.

regards,
dan carpenter


      parent reply	other threads:[~2013-02-19 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19 12:07 [PATCH 1/2] staging/sep: Fix smatch false positive about potential NULL dereference in sep_main.c Peter Huewe
2013-02-19 12:07 ` [PATCH 2/2] staging/sep: Check pointers before dereferencing (fix smatch warning) Peter Huewe
2013-02-19 12:25 ` Dan Carpenter [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=20130219122508.GA9138@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=rpjday@crashcourse.ca \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.