summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2022-05-27 18:28:16 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-07-02 17:39:23 +0300
commit09c9902cd80a07c2e69024f96f049985047e64b8 (patch)
tree32b4e263d78edc5c6563f7e8891ce6b8c2db912c
parentc4ff3ffe0138234774602152fe67e3a898c615c6 (diff)
downloadlinux-09c9902cd80a07c2e69024f96f049985047e64b8.tar.xz
bcache: memset on stack variables in bch_btree_check() and bch_sectors_dirty_init()
commit 7d6b902ea0e02b2a25c480edf471cbaa4ebe6b3c upstream. The local variables check_state (in bch_btree_check()) and state (in bch_sectors_dirty_init()) should be fully filled by 0, because before allocating them on stack, they were dynamically allocated by kzalloc(). Signed-off-by: Coly Li <colyli@suse.de> Link: https://lore.kernel.org/r/20220527152818.27545-2-colyli@suse.de Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/md/bcache/btree.c1
-rw-r--r--drivers/md/bcache/writeback.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index f64834785c8b..b47c00dea0f2 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -2017,6 +2017,7 @@ int bch_btree_check(struct cache_set *c)
if (c->root->level == 0)
return 0;
+ memset(&check_state, 0, sizeof(struct btree_check_state));
check_state.c = c;
check_state.total_threads = bch_btree_chkthread_nr();
check_state.key_idx = 0;
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 0145046a45f4..a878b959fbcd 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -901,6 +901,7 @@ void bch_sectors_dirty_init(struct bcache_device *d)
return;
}
+ memset(&state, 0, sizeof(struct bch_dirty_init_state));
state.c = c;
state.d = d;
state.total_threads = bch_btre_dirty_init_thread_nr();