[PATCH 2/2] xattr: prevent NULL ptr deref warnings in __simple_xattr_set

From: Sasha Levin
Date: Fri Sep 14 2012 - 15:35:43 EST


Prevent warnings generated by smatch due to unchecked dereference of
'new_xattr' in __simple_xattr_set().

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
fs/xattr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index 508ec1d..f24e5d5 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -880,7 +880,7 @@ static int __simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
if (flags & XATTR_REPLACE) {
xattr = new_xattr;
err = -ENODATA;
- } else {
+ } else if (new_xattr) {
list_add(&new_xattr->list, &xattrs->head);
xattr = NULL;
}
--
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/