From: Greg KH <gregkh@linuxfoundation.org>
To: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Cc: markus.elfring@web.de, almaz.alexandrovich@paragon-software.com,
linux-kernel@vger.kernel.org, ntfs3@lists.linux.dev,
stable@vger.kernel.org
Subject: Re: [PATCH v2] fs/ntfs3: Fix memory and resource leak in indx_find_sort
Date: Mon, 19 Jan 2026 07:37:50 +0100 [thread overview]
Message-ID: <2026011945-ammonia-sheet-d784@gregkh> (raw)
In-Reply-To: <20260118185736.41529-1-jiashengjiangcool@gmail.com>
On Sun, Jan 18, 2026 at 06:57:36PM +0000, Jiasheng Jiang wrote:
> The function indx_find_sort() incorrectly uses kfree(n) to cleanup the
> 'struct indx_node' instance in error paths.
>
> The 'struct indx_node' is a container that manages internal allocations
> (n->index) and holds a reference to a buffer head (n->nb). Using kfree()
> directly on the node pointer only frees the container itself, resulting
> in a memory leak of the index buffer and a resource leak of the buffer
> head reference.
>
> This patch replaces the incorrect kfree(n) calls with the specialized
> helper put_indx_node(n), which correctly releases the internal resources
> and the buffer head, consistent with other functions like indx_find_raw().
>
> Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
> ---
> Changelog:
>
> v1 -> v2:
>
> 1. Add a Fixes tag.
> ---
> fs/ntfs3/index.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
> index 7157cfd70fdc..c598b4b2f454 100644
> --- a/fs/ntfs3/index.c
> +++ b/fs/ntfs3/index.c
> @@ -1248,7 +1248,7 @@ int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
> sizeof(struct NTFS_DE) + sizeof(u64)) {
> if (n) {
> fnd_pop(fnd);
> - kfree(n);
> + put_indx_node(n);
> }
> return -EINVAL;
> }
> @@ -1261,7 +1261,7 @@ int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
> /* Try next level. */
> e = hdr_first_de(&n->index->ihdr);
> if (!e) {
> - kfree(n);
> + put_indx_node(n);
> return -EINVAL;
> }
>
> @@ -1281,7 +1281,7 @@ int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
> /* Pop one level. */
> if (n) {
> fnd_pop(fnd);
> - kfree(n);
> + put_indx_node(n);
> }
>
> level = fnd->level;
> --
> 2.25.1
>
>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
next prev parent reply other threads:[~2026-01-19 6:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <17914287-640d-4500-b519-5f3d3aed2878@web.de>
2026-01-18 18:57 ` [PATCH v2] fs/ntfs3: Fix memory and resource leak in indx_find_sort Jiasheng Jiang
2026-01-19 6:37 ` Greg KH [this message]
2026-01-19 10:00 ` Markus Elfring
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=2026011945-ammonia-sheet-d784@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=jiashengjiangcool@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.elfring@web.de \
--cc=ntfs3@lists.linux.dev \
--cc=stable@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