public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [cgroup:for-next 5/6] fs/xattr.c:882 __simple_xattr_set() error: potential NULL dereference 'new
Date: Wed, 12 Sep 2012 07:55:17 +0000	[thread overview]
Message-ID: <20120912075517.GZ19396@mwanda> (raw)
In-Reply-To: <20120912022813.GA17922@localhost>

On Wed, Sep 12, 2012 at 10:28:13AM +0800, Fengguang Wu wrote:
> Hi Aristeu,
> 
> FYI, there are new smatch warnings show up in
> 
> tree:   git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next
> head:   9814e970d7947dcc5ab7b37a53514c0098bfacc9
> commit: 38f38657444d15e1a8574eae80ed3de9f501737a xattr: extract simple_xattr code from tmpfs
> 
> 
> fs/xattr.c:882 __simple_xattr_set() error: potential NULL dereference 'new_xattr'.
> 

I don't know if this specific code is buggy or not.  It would depend
on how the function is called.

But potentially I should disable this Smatch rule.  It tends to have
a lot of false positives.  The thing is that GCC complains if you
don't initialize "new_xattr", but if you initialize it to NULL then
Smatch complains.

One solution might be to use the unitialized_var() macro.

-       struct simple_xattr *new_xattr = NULL;
+       struct simple_xattr *uninitialized_var(new_xattr);

That would make both GCC and Smatch happy.

regards,
dan carpenter


  reply	other threads:[~2012-09-12  7:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12  2:28 [cgroup:for-next 5/6] fs/xattr.c:882 __simple_xattr_set() error: potential NULL dereference 'new_xat Fengguang Wu
2012-09-12  7:55 ` Dan Carpenter [this message]
2012-09-12 13:40 ` [cgroup:for-next 5/6] fs/xattr.c:882 __simple_xattr_set() error: potential NULL dereference 'new Aristeu Rozanski

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=20120912075517.GZ19396@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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