[PATCH] gfs2: Fix memory leak in gfs2_make_fs_rw()

Qing Wong posted 1 patch 2 days, 1 hour ago
fs/gfs2/super.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] gfs2: Fix memory leak in gfs2_make_fs_rw()
Posted by Qing Wong 2 days, 1 hour ago
From: Qing Wang <wangqing7171@gmail.com>

If gfs2_quota_init() success and filesystem is withdrawn, need to cleanup
by gfs2_quota_cleanup() to avoid memory leak.

Reported-by: syzbot+e57495fb65020ac7bca4@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=e57495fb65020ac7bca4
Tested-by: syzbot+e57495fb65020ac7bca4@syzkaller.appspotmail.com
Fixes: 601ef0d52e96 ("gfs2: Force withdraw to replay journals and wait for it to finish")
Signed-off-by: Qing Wang <wangqing7171@gmail.com>
---
 fs/gfs2/super.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index f6cd907b3ec6..efa0e2452bc7 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -147,8 +147,10 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
 	}
 
 	error = gfs2_quota_init(sdp);
-	if (!error && gfs2_withdrawn(sdp))
-		error = -EIO;
+	if (!error && gfs2_withdrawn(sdp)) {
+		gfs2_quota_cleanup(sdp);
+		return -EIO;
+	}
 	if (!error)
 		set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
 	return error;
-- 
2.43.0