All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Potter <phil@philpotter.co.uk>
To: tytso@mit.edu
Cc: adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] fs: ext4: mballoc: amend goto to cleanup groupinfo memory correctly
Date: Mon, 12 Apr 2021 08:38:37 +0100	[thread overview]
Message-ID: <20210412073837.1686-1-phil@philpotter.co.uk> (raw)

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: syzbot+aa12d6106ea4ca1b6aae@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 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


             reply	other threads:[~2021-04-12  7:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  7:38 Phillip Potter [this message]
2021-05-01  9:18 ` [PATCH] fs: ext4: mballoc: amend goto to cleanup groupinfo memory correctly Phillip Potter
2021-05-01 17:43   ` Andreas Dilger
2021-05-02 10:49     ` Phillip Potter
2021-05-21  3:52       ` Theodore Y. Ts'o
2021-05-21  7:31         ` Phillip Potter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412073837.1686-1-phil@philpotter.co.uk \
    --to=phil@philpotter.co.uk \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.