]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ntfs3: fix memory leak in indx_create_allocate()
authorDeepanshu Kartikey <kartikey406@gmail.com>
Mon, 23 Mar 2026 05:21:48 +0000 (10:51 +0530)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Thu, 2 Apr 2026 18:23:23 +0000 (20:23 +0200)
When indx_create_allocate() fails after
attr_allocate_clusters() succeeds, run_deallocate()
frees the disk clusters but never frees the memory
allocated by run_add_entry() via kvmalloc() for the
runs_tree structure.

Fix this by adding run_close() at the out: label to
free the run.runs memory on all error paths. The
success path is unaffected as it returns 0 directly
without going through out:, transferring ownership
of the run memory to indx->alloc_run via memcpy().

Reported-by: syzbot+7adcddaeeb860e5d3f2f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7adcddaeeb860e5d3f2f
Signed-off-by: Deepanshu Kartikey <Kartikey406@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/index.c

index 8b107b6714ce0f154d618640622254c205d50ed6..5344b29b0577f53c592e7b1a585ae39df38823e3 100644 (file)
@@ -1482,6 +1482,7 @@ out1:
        run_deallocate(sbi, &run, false);
 
 out:
+       run_close(&run);
        return err;
 }