]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs: fix hole runlist memory leak in insert range error path
authorPeiyang He <peiyang_he@smail.nju.edu.cn>
Sun, 5 Jul 2026 11:14:09 +0000 (19:14 +0800)
committerNamjae Jeon <linkinjeon@kernel.org>
Mon, 6 Jul 2026 11:27:15 +0000 (20:27 +0900)
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>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/attrib.c

index e5e3bc03ad493756120c9ba5dda9d6f909d8eb6f..239b7bcbaedf4c2d0bd51529a93c45bbd0eb0352 100644 (file)
@@ -5328,6 +5328,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;
        }