* [PATCH] ntfs: fix hole runlist memory leak in insert range error path
@ 2026-07-05 10:05 Peiyang He
2026-07-05 10:13 ` Greg KH
2026-07-05 11:14 ` [PATCH v2] " Peiyang He
0 siblings, 2 replies; 5+ messages in thread
From: Peiyang He @ 2026-07-05 10:05 UTC (permalink / raw)
To: Namjae Jeon, Hyunchul Lee; +Cc: linux-fsdevel, linux-kernel, stable
ntfs_non_resident_attr_insert_range() allocates hole_rl before mapping the
whole runlist. If ntfs_attr_map_whole_runlist() fails, the error path drops
ni->runlist.lock and returns without freeing hole_rl. This causes memory leak
of sizeof(*hole_rl) * 2 bytes.
Fix this memory leak by freeing hole_rl before returning from that error path,
matching the later error paths in the same function.
Fixes: 495e90fa3348 ("ntfs: update attrib operations")
Signed-off-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
---
fs/ntfs/attrib.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index dd8828098511..55603df0a2ed 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -5325,6 +5325,7 @@ int ntfs_non_resident_attr_insert_range(struct ntfs_inode *ni, s64 start_vcn, s6
ret = ntfs_attr_map_whole_runlist(ni);
if (ret) {
up_write(&ni->runlist.lock);
+ kfree(hole_rl);
return ret;
}
base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ntfs: fix hole runlist memory leak in insert range error path
2026-07-05 10:05 [PATCH] ntfs: fix hole runlist memory leak in insert range error path Peiyang He
@ 2026-07-05 10:13 ` Greg KH
2026-07-05 11:14 ` [PATCH v2] " Peiyang He
1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-07-05 10:13 UTC (permalink / raw)
To: Peiyang He; +Cc: Namjae Jeon, Hyunchul Lee, linux-fsdevel, linux-kernel, stable
On Sun, Jul 05, 2026 at 06:05:54PM +0800, Peiyang He wrote:
> ntfs_non_resident_attr_insert_range() allocates hole_rl before mapping the
> whole runlist. If ntfs_attr_map_whole_runlist() fails, the error path drops
> ni->runlist.lock and returns without freeing hole_rl. This causes memory leak
> of sizeof(*hole_rl) * 2 bytes.
>
> Fix this memory leak by freeing hole_rl before returning from that error path,
> matching the later error paths in the same function.
>
> Fixes: 495e90fa3348 ("ntfs: update attrib operations")
> Signed-off-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
> ---
> fs/ntfs/attrib.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
> index dd8828098511..55603df0a2ed 100644
> --- a/fs/ntfs/attrib.c
> +++ b/fs/ntfs/attrib.c
> @@ -5325,6 +5325,7 @@ int ntfs_non_resident_attr_insert_range(struct ntfs_inode *ni, s64 start_vcn, s6
> ret = ntfs_attr_map_whole_runlist(ni);
> if (ret) {
> up_write(&ni->runlist.lock);
> + kfree(hole_rl);
> return ret;
> }
>
>
> base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
> --
> 2.43.0
>
>
<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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] ntfs: fix hole runlist memory leak in insert range error path
2026-07-05 10:05 [PATCH] ntfs: fix hole runlist memory leak in insert range error path Peiyang He
2026-07-05 10:13 ` Greg KH
@ 2026-07-05 11:14 ` Peiyang He
2026-07-06 0:25 ` Hyunchul Lee
2026-07-06 11:31 ` Namjae Jeon
1 sibling, 2 replies; 5+ messages in thread
From: Peiyang He @ 2026-07-05 11:14 UTC (permalink / raw)
To: Namjae Jeon, Hyunchul Lee; +Cc: linux-fsdevel, linux-kernel, stable
ntfs_non_resident_attr_insert_range() allocates hole_rl before mapping the
whole runlist. If ntfs_attr_map_whole_runlist() fails, the error path drops
ni->runlist.lock and returns without freeing hole_rl. This leaks memory
of sizeof(*hole_rl) * 2 bytes.
Fix this memory leak by freeing hole_rl before returning from
that error path, matching the later error paths in the same function.
Fixes: 495e90fa3348 ("ntfs: update attrib operations")
Cc: stable@vger.kernel.org
Signed-off-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
---
Changes in v2:
- modify commit message to resolve checkpatch.pl warning
- add Cc: stable@vger.kernel.org tag to the commit message
fs/ntfs/attrib.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index dd8828098511..55603df0a2ed 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -5325,6 +5325,7 @@ int ntfs_non_resident_attr_insert_range(struct ntfs_inode *ni, s64 start_vcn, s6
ret = ntfs_attr_map_whole_runlist(ni);
if (ret) {
up_write(&ni->runlist.lock);
+ kfree(hole_rl);
return ret;
}
base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ntfs: fix hole runlist memory leak in insert range error path
2026-07-05 11:14 ` [PATCH v2] " Peiyang He
@ 2026-07-06 0:25 ` Hyunchul Lee
2026-07-06 11:31 ` Namjae Jeon
1 sibling, 0 replies; 5+ messages in thread
From: Hyunchul Lee @ 2026-07-06 0:25 UTC (permalink / raw)
To: Peiyang He; +Cc: Namjae Jeon, linux-fsdevel, linux-kernel, stable
2026년 7월 5일 (일) 오후 8:14, Peiyang He <peiyang_he@smail.nju.edu.cn>님이 작성:
>
> ntfs_non_resident_attr_insert_range() allocates hole_rl before mapping the
> whole runlist. If ntfs_attr_map_whole_runlist() fails, the error path drops
> ni->runlist.lock and returns without freeing hole_rl. This leaks memory
> of sizeof(*hole_rl) * 2 bytes.
>
> Fix this memory leak by freeing hole_rl before returning from
> that error path, matching the later error paths in the same function.
>
> Fixes: 495e90fa3348 ("ntfs: update attrib operations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
Looks good to me.
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
> Changes in v2:
> - modify commit message to resolve checkpatch.pl warning
> - add Cc: stable@vger.kernel.org tag to the commit message
>
> fs/ntfs/attrib.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
> index dd8828098511..55603df0a2ed 100644
> --- a/fs/ntfs/attrib.c
> +++ b/fs/ntfs/attrib.c
> @@ -5325,6 +5325,7 @@ int ntfs_non_resident_attr_insert_range(struct ntfs_inode *ni, s64 start_vcn, s6
> ret = ntfs_attr_map_whole_runlist(ni);
> if (ret) {
> up_write(&ni->runlist.lock);
> + kfree(hole_rl);
> return ret;
> }
>
>
> base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
> --
> 2.43.0
>
--
Thanks,
Hyunchul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ntfs: fix hole runlist memory leak in insert range error path
2026-07-05 11:14 ` [PATCH v2] " Peiyang He
2026-07-06 0:25 ` Hyunchul Lee
@ 2026-07-06 11:31 ` Namjae Jeon
1 sibling, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2026-07-06 11:31 UTC (permalink / raw)
To: Peiyang He; +Cc: Hyunchul Lee, linux-fsdevel, linux-kernel, stable
On Sun, Jul 5, 2026 at 8:14 PM Peiyang He <peiyang_he@smail.nju.edu.cn> wrote:
>
> ntfs_non_resident_attr_insert_range() allocates hole_rl before mapping the
> whole runlist. If ntfs_attr_map_whole_runlist() fails, the error path drops
> ni->runlist.lock and returns without freeing hole_rl. This leaks memory
> of sizeof(*hole_rl) * 2 bytes.
>
> Fix this memory leak by freeing hole_rl before returning from
> that error path, matching the later error paths in the same function.
>
> Fixes: 495e90fa3348 ("ntfs: update attrib operations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
Applied it to #ntfs-next.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-06 11:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-05 10:05 [PATCH] ntfs: fix hole runlist memory leak in insert range error path Peiyang He
2026-07-05 10:13 ` Greg KH
2026-07-05 11:14 ` [PATCH v2] " Peiyang He
2026-07-06 0:25 ` Hyunchul Lee
2026-07-06 11:31 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox