From: Phillip Potter Date: Mon, 12 Apr 2021 07:38:37 +0000 (+0100) Subject: ext4: fix memory leak in ext4_mb_init_backend on error path. X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a8867f4e3809050571c98de7a2d465aff5e4daf5;p=linux.git ext4: fix memory leak in ext4_mb_init_backend on error path. Fix a memory leak discovered by syzbot when a file system is corrupted with an illegally large s_log_groups_per_flex. Reported-by: syzbot+aa12d6106ea4ca1b6aae@syzkaller.appspotmail.com Signed-off-by: Phillip Potter Cc: stable@kernel.org Link: https://lore.kernel.org/r/20210412073837.1686-1-phil@philpotter.co.uk Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 3239e6669e843..c2c22c2baac0b 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3217,7 +3217,7 @@ static int ext4_mb_init_backend(struct super_block *sb) */ if (sbi->s_es->s_log_groups_per_flex >= 32) { ext4_msg(sb, KERN_ERR, "too many log groups per flexible block group"); - goto err_freesgi; + goto err_freebuddy; } sbi->s_mb_prefetch = min_t(uint, 1 << sbi->s_es->s_log_groups_per_flex, BLK_MAX_SEGMENT_SIZE >> (sb->s_blocksize_bits - 9));