Skip to content

Commit

Permalink
bcache: memset on stack variables in bch_btree_check() and bch_sector…
Browse files Browse the repository at this point in the history
…s_dirty_init()

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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Coly Li authored and axboe committed May 27, 2022
1 parent b9684a7 commit 7d6b902
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/md/bcache/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/md/bcache/writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,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();
Expand Down

0 comments on commit 7d6b902

Please sign in to comment.