]> git.hungrycats.org Git - linux/commit
btrfs: fix uninitialized return value in the ref-verify tool
authorFilipe Manana <fdmanana@suse.com>
Sun, 23 Jun 2024 11:50:26 +0000 (12:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2024 07:53:38 +0000 (09:53 +0200)
commit437c04320666e8c19dde52f1ba8cea8656c2aa91
tree76e31a8ea8dbc813a50587379618dcc22062b362
parent8a500b3a5f0a58c6f99039091fbd715f64f2f8af
btrfs: fix uninitialized return value in the ref-verify tool

[ Upstream commit 9da45c88e124f13a3c4d480b89b298e007fbb9e4 ]

In the ref-verify tool, when processing the inline references of an extent
item, we may end up returning with uninitialized return value, because:

1) The 'ret' variable is not initialized if there are no inline extent
   references ('ptr' == 'end' before the while loop starts);

2) If we find an extent owner inline reference we don't initialize 'ret'.

So fix these cases by initializing 'ret' to 0 when declaring the variable
and set it to -EINVAL if we find an extent owner inline references and
simple quotas are not enabled (as well as print an error message).

Reported-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/59b40ebe-c824-457d-8b24-0bbca69d472b@gmail.com/
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/ref-verify.c