Skip to content

Commit 66691c6

Browse files
jroimartinkdave
authored andcommitted
btrfs: fix uninitialized pointer free in add_inode_ref()
The add_inode_ref() function does not initialize the "name" struct when it is declared. If any of the following calls to "read_one_inode() returns NULL, dir = read_one_inode(root, parent_objectid); if (!dir) { ret = -ENOENT; goto out; } inode = read_one_inode(root, inode_objectid); if (!inode) { ret = -EIO; goto out; } then "name.name" would be freed on "out" before being initialized. out: ... kfree(name.name); This issue was reported by Coverity with CID 1526744. Fixes: e43eec8 ("btrfs: use struct qstr instead of name and namelen pairs") CC: [email protected] # 6.6+ Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Roi Martin <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 97420be commit 66691c6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/tree-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
13741374
struct inode *inode = NULL;
13751375
unsigned long ref_ptr;
13761376
unsigned long ref_end;
1377-
struct fscrypt_str name;
1377+
struct fscrypt_str name = { 0 };
13781378
int ret;
13791379
int log_ref_ver = 0;
13801380
u64 parent_objectid;

0 commit comments

Comments
 (0)