2021-04-12 07:39:37

by Phillip Potter

[permalink] [raw]
Subject: [PATCH] fs: ext4: mballoc: amend goto to cleanup groupinfo memory correctly

When flexible block groups are enabled on a filesystem, and there are
too many log groups per flexible block group, goto err_freebuddy rather
than err_freesgi within ext4_mb_init_backend. Cleanup code for new_inode
and successive executions of ext4_mb_add_groupinfo in the previous loop
is then correctly run. Fixes memory leak reported by syzbot at:
https://syzkaller.appspot.com/bug?extid=aa12d6106ea4ca1b6aae

Reported-by: [email protected]
Signed-off-by: Phillip Potter <[email protected]>
---
fs/ext4/mballoc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a02fadf4fc84..d24cb3dc79ff 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2715,7 +2715,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));
--
2.30.2


2021-05-01 09:18:34

by Phillip Potter

[permalink] [raw]
Subject: Re: [PATCH] fs: ext4: mballoc: amend goto to cleanup groupinfo memory correctly

Hi All,

Sorry to be pushy (I know everyone is busy) but I've had no feedback on
this patch yet:
https://lore.kernel.org/linux-ext4/[email protected]/T/#u

Could I please ask for it to be reviewed? Many thanks.

Regards,
Phil Potter

2021-05-01 17:45:58

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH] fs: ext4: mballoc: amend goto to cleanup groupinfo memory correctly

On May 1, 2021, at 02:18, Phillip Potter <[email protected]> wrote:
>
> ´╗┐Hi All,
>
> Sorry to be pushy (I know everyone is busy) but I've had no feedback on
> this patch yet:
> https://lore.kernel.org/linux-ext4/[email protected]/T/#u
>
> Could I please ask for it to be reviewed? Many thanks.

Hi Phil,
I've looked at the patch and it looks good. You can add my:

Reviewed-by: Andreas Dilger <[email protected]>

Note in the future that it is a bit easier to review (IMHO) if you include the
original patch in your ping email, but not a big deal.

Cheers, Andreas

2021-05-21 09:35:44

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] fs: ext4: mballoc: amend goto to cleanup groupinfo memory correctly

Thanks, applied, with a cleaned up commit description.

Cheers,

- Ted