public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Wu Guanghao <wuguanghao3@huawei.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, yangyun50@huawei.com
Subject: Re: [PATCH 2/2] resize: fix memory leak when exiting normally
Date: Tue, 18 Nov 2025 10:29:19 -0800	[thread overview]
Message-ID: <20251118182919.GP196358@frogsfrogsfrogs> (raw)
In-Reply-To: <20251118132601.2756185-3-wuguanghao3@huawei.com>

On Tue, Nov 18, 2025 at 09:26:01PM +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>
> ---
>  resize/main.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/resize/main.c b/resize/main.c
> index 08a4bbaf..71711229 100644
> --- a/resize/main.c
> +++ b/resize/main.c
> @@ -702,6 +702,8 @@ int main (int argc, char ** argv)
>  	}
>  	if (fd > 0)
>  		close(fd);
> +
> +	(void) ext2fs_close_free(&fs);

You might want to capture and print an error if one is returned, because
ext2fs_close_free will also flush the new metadata to disk.

--D

>  	remove_error_table(&et_ext2_error_table);
>  	return 0;
>  errout:
> -- 
> 2.27.0
> 
> 

  reply	other threads:[~2025-11-18 18:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 13:25 [PATCH 0/2] e2fsprogs: fix memory leaks detected by ASAN Wu Guanghao
2025-11-18 13:26 ` [PATCH 1/2] fsck: fix memory leak of inst->type Wu Guanghao
2025-11-18 18:30   ` Darrick J. Wong
2025-11-19  1:25     ` Wu Guanghao
2025-11-19  6:32       ` Darrick J. Wong
2025-11-18 13:26 ` [PATCH 2/2] resize: fix memory leak when exiting normally Wu Guanghao
2025-11-18 18:29   ` Darrick J. Wong [this message]
2025-11-19  1:52     ` Wu Guanghao
2025-11-19  6:26       ` Darrick J. Wong
2025-11-20  3:45         ` Wu Guanghao

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=20251118182919.GP196358@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --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