From: Aristeu Rozanski <aris@redhat.com>
To: kernel-janitors@vger.kernel.org
Subject: [PATCH] xattr: mark variable as uninitialized to make both gcc and smatch happy
Date: Wed, 12 Sep 2012 14:31:13 +0000 [thread overview]
Message-ID: <20120912143112.GE19694@redhat.com> (raw)
new_xattr in __simple_xattr_set() is only initialized with a valid
pointer if value is not NULL, which only happens if this function is
called directly with the intention to remove an existing extended
attribute. Even being safe to be this way, smatch warns about possible
NULL dereference. Dan Carpenter suggested using uninitialized_var()
which will make both gcc and smatch happy.
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
---
fs/xattr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/fs/xattr.c 2012-09-12 09:57:35.000000000 -0400
+++ b/fs/xattr.c 2012-09-12 09:58:25.619387047 -0400
@@ -845,7 +845,7 @@ static int __simple_xattr_set(struct sim
const void *value, size_t size, int flags)
{
struct simple_xattr *xattr;
- struct simple_xattr *new_xattr = NULL;
+ struct simple_xattr *uninitialized_var(new_xattr);
int err = 0;
/* value = NULL means remove */
next reply other threads:[~2012-09-12 14:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-12 14:31 Aristeu Rozanski [this message]
2012-09-12 18:42 ` [PATCH] xattr: mark variable as uninitialized to make both gcc and smatch happy Tejun Heo
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=20120912143112.GE19694@redhat.com \
--to=aris@redhat.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