public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Tso" <tytso@mit.edu>
To: Wu Guanghao <wuguanghao3@huawei.com>
Cc: linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca,
	djwong@kernel.org, yangyun50@huawei.com
Subject: Re: [PATCH v2 2/2] resize: fix memory leak when exiting normally
Date: Thu, 5 Mar 2026 12:38:35 -0500	[thread overview]
Message-ID: <20260305173835.GA9095@macsyma.local> (raw)
In-Reply-To: <20251121033612.2423536-3-wuguanghao3@huawei.com>

On Fri, Nov 21, 2025 at 11:36:12AM +0800, Wu Guanghao wrote:
> The main() function only releases fs when it exits through the errout or
> success_exit labels. When completes normally, it does not release fs.
> 
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>

I'm guessing you only tested the online resize code path?

	if (mount_flags & EXT2_MF_MOUNTED) {
		retval = online_resize_fs(fs, mtpt, &new_size, flags);
	} else {
	       ...
		retval = resize_fs(fs, &new_size, flags,
				   ((flags & RESIZE_PERCENT_COMPLETE) ?
				    resize_progress_func : 0));
	}

The reason why I ask this is that resize_fs() frees fs on the success path:

	rfs->old_fs = fs;
	...
	ext2fs_free(rfs->old_fs);
	
... although if we return when an error, we do *not* free ext2fs_free(rfs->old_fs).

So if you were to test with this applied when resizing a non-mounted
file system, I believe you'd get a double free failure.

Cheers,

							- Ted

      reply	other threads:[~2026-03-05 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  3:36 [PATCH v2 0/2] e2fsprogs: fix memory leaks detected by ASAN Wu Guanghao
2025-11-21  3:36 ` [PATCH v2 1/2] fsck: fix memory leak of inst->type Wu Guanghao
2025-11-21 16:23   ` Darrick J. Wong
2025-11-21  3:36 ` [PATCH v2 2/2] resize: fix memory leak when exiting normally Wu Guanghao
2026-03-05 17:38   ` Theodore Tso [this message]

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=20260305173835.GA9095@macsyma.local \
    --to=tytso@mit.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=djwong@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=wuguanghao3@huawei.com \
    --cc=yangyun50@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox