Skip to content

Commit 87ac077

Browse files
deepanshu406aalexandrovich
authored andcommitted
ntfs3: fix memory leak in indx_create_allocate()
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>
1 parent f9963de commit 87ac077

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/ntfs3/index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,7 @@ static int indx_create_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
14821482
run_deallocate(sbi, &run, false);
14831483

14841484
out:
1485+
run_close(&run);
14851486
return err;
14861487
}
14871488

0 commit comments

Comments
 (0)