From: Will Rosenberg <whrosenb@asu.edu>
To: Paul Moore <paul@paul-moore.com>
Cc: Oliver Rosenberg <olrose55@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Tejun Heo <tj@kernel.org>,
Casey Schaufler <casey@schaufler-ca.com>,
Ondrej Mosnacek <omosnace@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] kernfs: fix memory leak of kernfs_iattrs in __kernfs_new_node
Date: Tue, 25 Nov 2025 08:11:40 -0700 [thread overview]
Message-ID: <aSXHLOdujmeUDELo@gmail.com> (raw)
In-Reply-To: <CAHC9VhRwBmC+8iMk8rFbDdwCy+=_unNMybC=HQN=+v5v-nkE8g@mail.gmail.com>
On Mon, Nov 24, 2025 at 03:41:51PM -0500, Paul Moore wrote:
>
> Should this be kmem_cache_free(kernfs_iattrs_cache, kn->iattr)
> instead? I suspect it would also probably be a good idea to call
> simple_xattrs_free() first.
>
> I also noticed there is a reasonable amount of duplicated kernfs
> cleanup code spread around fs/kernfs/dir.c, we could probably benefit
> from some helper functions here, but that would be a follow-on patch;
> keeping a small bugfix patch to ease stable tree backporting is a good
> thing.
I agree. Helper functions could also help prevent this type of bug from
re-emerging.
> [HINT FOR THE FUTURE: for patches like this, look for a function that
> normally does resource cleanup for the object and do what it does, in
> this case kernfs_free_rcu() is a good example.]
Thank you for all the help. I updated kfree to kmem_cache_free() and
added simple_xattrs_free() just to be safe for future changes.
--
will rosenberg
next prev parent reply other threads:[~2025-11-25 15:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 16:02 [PATCH v2] kernfs: fix memory leak of kernfs_iattrs in __kernfs_new_node Will Rosenberg
2025-11-24 16:15 ` Greg Kroah-Hartman
2025-11-24 18:37 ` [PATCH v3] " Will Rosenberg
2025-11-24 20:41 ` Paul Moore
2025-11-25 15:11 ` Will Rosenberg [this message]
2025-11-25 15:13 ` [PATCH v4] " Will Rosenberg
2025-12-07 21:45 ` Paul Moore
2025-12-07 22:28 ` Will Rosenberg
2025-12-07 22:38 ` Paul Moore
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=aSXHLOdujmeUDELo@gmail.com \
--to=whrosenb@asu.edu \
--cc=casey@schaufler-ca.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olrose55@gmail.com \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=tj@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