From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued
Date: Tue, 4 Nov 2025 08:59:19 -0800 [thread overview]
Message-ID: <20251104165919.GJ196370@frogsfrogsfrogs> (raw)
In-Reply-To: <20251104104301.2417171-1-hch@lst.de>
On Tue, Nov 04, 2025 at 05:43:01AM -0500, Christoph Hellwig wrote:
> kmemleak occasionally reports leaking xfs_busy_extents structure
> from xfs_scrub calls after running xfs/528 (but attributed to following
> tests), which seems to be caused by not freeing the xfs_busy_extents
> structure when tr.queued is 0 and xfs_trim_rtgroup_extents breaks out
> of the main loop. Free the structure in this case.
>
> Fixes: a3315d11305f ("xfs: use rtgroup busy extent list for FITRIM")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Yep, this fixes a memory leak. I wonder if you could combine the two
into:
if (error || !tr.queued) {
kfree(tr.extents);
break;
}
But I don't care passionately either way.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_discard.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> index ee49f20875af..6917de832191 100644
> --- a/fs/xfs/xfs_discard.c
> +++ b/fs/xfs/xfs_discard.c
> @@ -726,8 +726,10 @@ xfs_trim_rtgroup_extents(
> break;
> }
>
> - if (!tr.queued)
> + if (!tr.queued) {
> + kfree(tr.extents);
> break;
> + }
>
> /*
> * We hand the extent list to the discard function here so the
> --
> 2.47.3
>
>
next prev parent reply other threads:[~2025-11-04 16:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 10:43 [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued Christoph Hellwig
2025-11-04 16:59 ` Darrick J. Wong [this message]
2025-11-05 19:45 ` Christoph Hellwig
2025-11-06 13:27 ` Carlos Maiolino
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=20251104165919.GJ196370@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/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