bcachefs: Fix uninitialized data in bch2_gc_btree()
authorJustin Husted <sigstop@gmail.com>
Wed, 9 Oct 2019 02:16:28 +0000 (19:16 -0700)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:29 +0000 (17:08 -0400)
Running the filesystem under valgrind exposed a path where the max_stale
variable in bch2_gc_btree() might not be initialized before use in a
rare case when there are no btree nodes in a transaction.

Signed-off-by: Justin Husted <sigstop@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_gc.c

index f8485fba55e2bb4d7b9dcb34aa96cdc8b2f193c1..f7d9abfdb3dea1c2435c290716c742fae159ee05 100644 (file)
@@ -218,7 +218,7 @@ static int bch2_gc_btree(struct bch_fs *c, enum btree_id btree_id,
                : expensive_debug_checks(c)             ? 0
                : !btree_node_type_needs_gc(btree_id)   ? 1
                : 0;
-       u8 max_stale;
+       u8 max_stale = 0;
        int ret = 0;
 
        bch2_trans_init(&trans, c, 0, 0);