btrfs: fix uninitialized pointer free on read_alloc_one_name() error
authorRoi Martin <jroi.martin@gmail.com>
Thu, 10 Oct 2024 19:47:17 +0000 (21:47 +0200)
committerDavid Sterba <dsterba@suse.com>
Fri, 11 Oct 2024 17:55:04 +0000 (19:55 +0200)
commit2ab5e243c2266c841e0f6904fad1514b18eaf510
tree2e394de58edc1fda8f57924205d1db530b9613d6
parenta0af4936e4a89e0006c73d5f9e969a613c99a655
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 e43eec81c516 ("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: e43eec81c516 ("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>
fs/btrfs/tree-log.c