* [PATCH] xattr: mark variable as uninitialized to make both gcc and smatch happy
@ 2012-09-12 14:31 Aristeu Rozanski
2012-09-12 18:42 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Aristeu Rozanski @ 2012-09-12 14:31 UTC (permalink / raw)
To: kernel-janitors
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 */
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] xattr: mark variable as uninitialized to make both gcc and smatch happy
2012-09-12 14:31 [PATCH] xattr: mark variable as uninitialized to make both gcc and smatch happy Aristeu Rozanski
@ 2012-09-12 18:42 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2012-09-12 18:42 UTC (permalink / raw)
To: kernel-janitors
On Wed, Sep 12, 2012 at 10:31:13AM -0400, Aristeu Rozanski wrote:
> 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>
applied to cgroup/for-3.7. Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-12 18:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-12 14:31 [PATCH] xattr: mark variable as uninitialized to make both gcc and smatch happy Aristeu Rozanski
2012-09-12 18:42 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox