Skip to content

Commit 2ab5e24

Browse files
jroimartinkdave
authored andcommitted
btrfs: fix uninitialized pointer free on read_alloc_one_name() error
The function read_alloc_one_name() does not initialize the name field of the passed fscrypt_str struct if kmalloc fails to allocate the corresponding buffer. Thus, it is not guaranteed that fscrypt_str.name is initialized when freeing it. This is a follow-up to the linked patch that fixes the remaining instances of the bug introduced by commit e43eec8 ("btrfs: use struct qstr instead of name and namelen pairs"). Link: https://lore.kernel.org/linux-btrfs/20241009080833.1355894-1-jroi.martin@gmail.com/ Fixes: e43eec8 ("btrfs: use struct qstr instead of name and namelen pairs") CC: stable@vger.kernel.org # 6.1+ Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Roi Martin <jroi.martin@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent a0af493 commit 2ab5e24

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/tree-log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
18451845
struct btrfs_dir_item *di,
18461846
struct btrfs_key *key)
18471847
{
1848-
struct fscrypt_str name;
1848+
struct fscrypt_str name = { 0 };
18491849
struct btrfs_dir_item *dir_dst_di;
18501850
struct btrfs_dir_item *index_dst_di;
18511851
bool dir_dst_matches = false;
@@ -2125,7 +2125,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
21252125
struct extent_buffer *eb;
21262126
int slot;
21272127
struct btrfs_dir_item *di;
2128-
struct fscrypt_str name;
2128+
struct fscrypt_str name = { 0 };
21292129
struct inode *inode = NULL;
21302130
struct btrfs_key location;
21312131

0 commit comments

Comments
 (0)