Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ntfs: fix error handling in ntfs_write_iomap_end_resident()

When ntfs_attr_get_search_ctx() fails and returns NULL, the function
returned early without calling put_page(ipage).
Fix this by jumping to err_out label on error. The err_out path now
properly releases the page and the mutex, with a NULL check for
the search context.

Reported-by: DaeMyung Kang <charsyam@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

+3 -3
+3 -3
fs/ntfs/iomap.c
··· 788 788 ctx = ntfs_attr_get_search_ctx(ni, NULL); 789 789 if (!ctx) { 790 790 written = -ENOMEM; 791 - mutex_unlock(&ni->mrec_lock); 792 - return written; 791 + goto err_out; 793 792 } 794 793 795 794 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, ··· 809 810 memcpy(kattr + pos, iomap_inline_data(iomap, pos), written); 810 811 mark_mft_record_dirty(ctx->ntfs_ino); 811 812 err_out: 812 - ntfs_attr_put_search_ctx(ctx); 813 + if (ctx) 814 + ntfs_attr_put_search_ctx(ctx); 813 815 put_page(ipage); 814 816 mutex_unlock(&ni->mrec_lock); 815 817 return written;