Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: avoid null dereference in f2fs_acl_from_disk

This patch resolves Coverity #751303:

>>> CID 753103: Explicit null dereferenced (FORWARD_NULL) Passing null
>>> pointer "value" to function "f2fs_acl_from_disk(char const *, size_t)",
which dereferences it.

[Error path]
- value = NULL;
- retval = 0 by f2fs_getxattr();
- f2fs_acl_from_disk(value:NULL, ...);

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>

+6 -7
+6 -7
fs/f2fs/acl.c
··· 191 191 retval = f2fs_getxattr(inode, name_index, "", value, retval); 192 192 } 193 193 194 - if (retval < 0) { 195 - if (retval == -ENODATA) 196 - acl = NULL; 197 - else 198 - acl = ERR_PTR(retval); 199 - } else { 194 + if (retval > 0) 200 195 acl = f2fs_acl_from_disk(value, retval); 201 - } 196 + else if (retval == -ENODATA) 197 + acl = NULL; 198 + else 199 + acl = ERR_PTR(retval); 202 200 kfree(value); 201 + 203 202 if (!IS_ERR(acl)) 204 203 set_cached_acl(inode, type, acl); 205 204