Skip to content

Commit 785bc56

Browse files
committed
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>
1 parent cad7c6f commit 785bc56

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

fs/ntfs/iomap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,7 @@ static int ntfs_write_iomap_end_resident(struct inode *inode, loff_t pos,
788788
ctx = ntfs_attr_get_search_ctx(ni, NULL);
789789
if (!ctx) {
790790
written = -ENOMEM;
791-
mutex_unlock(&ni->mrec_lock);
792-
return written;
791+
goto err_out;
793792
}
794793

795794
err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
@@ -810,7 +809,8 @@ static int ntfs_write_iomap_end_resident(struct inode *inode, loff_t pos,
810809
memcpy(kattr + pos, iomap_inline_data(iomap, pos), written);
811810
mark_mft_record_dirty(ctx->ntfs_ino);
812811
err_out:
813-
ntfs_attr_put_search_ctx(ctx);
812+
if (ctx)
813+
ntfs_attr_put_search_ctx(ctx);
814814
put_page(ipage);
815815
mutex_unlock(&ni->mrec_lock);
816816
return written;

0 commit comments

Comments
 (0)