diff options
author | Jan Kara <jack@suse.cz> | 2022-09-22 11:09:29 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-09-28 11:32:28 +0200 |
commit | cdefe8dd61c9030f74e5f6b549af9ca81ddf561d (patch) | |
tree | ef348cb26c65a5e2c4f0247ec516a8ace3ec254c | |
parent | 48a12961e800aa404fefa845aa95098d18a30f19 (diff) |
ext4: fixup possible uninitialized variable access in ext4_mb_choose_next_group_cr1()
commit a078dff870136090b5779ca2831870a6c5539d36 upstream.
Variable 'grp' may be left uninitialized if there's no group with
suitable average fragment size (or larger). Fix the problem by
initializing it earlier.
Link: https://lore.kernel.org/r/20220922091542.pkhedytey7wzp5fi@quack3
Fixes: 83e80a6e3543 ("ext4: use buckets for cr 1 block scan instead of rbtree")
Cc: stable@kernel.org
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/ext4/mballoc.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index bf4ec1c06572..fd29e15d1c3b 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -910,7 +910,7 @@ static void ext4_mb_choose_next_group_cr1(struct ext4_allocation_context *ac, int *new_cr, ext4_group_t *group, ext4_group_t ngroups) { struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); - struct ext4_group_info *grp, *iter; + struct ext4_group_info *grp = NULL, *iter; int i; if (unlikely(ac->ac_flags & EXT4_MB_CR1_OPTIMIZED)) { @@ -927,7 +927,6 @@ static void ext4_mb_choose_next_group_cr1(struct ext4_allocation_context *ac, read_unlock(&sbi->s_mb_avg_fragment_size_locks[i]); continue; } - grp = NULL; list_for_each_entry(iter, &sbi->s_mb_avg_fragment_size[i], bb_avg_fragment_size_node) { if (sbi->s_mb_stats) |