ntfs: do not dereference a null ctx on error
PATCH 1/1 ntfs: do not dereference a null ctx on error
In ntfs_mft_data_extend_allocation_nolock(), if an error condition occurs prior to 'ctx' being set to a non-NULL value, avoid dereferencing the NULL 'ctx' pointer by jumping to later cleanup code.
Signed-off-by Nickolai Zeldovich <[email protected]>
--- fs/ntfs/mft.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/ntfs/mft.c +4 -4
@@ -1822,13 +1822,13 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)if (IS_ERR (mrec)) {ntfs_error (vol->sb,"Failed to map mft record." ); ret =PTR_ERR (mrec); - goto undo_alloc; + goto undo_alloc_noctx; } ctx =ntfs_attr_get_search_ctx (mft_ni, mrec);if (unlikely (!ctx)) {ntfs_error (vol->sb,"Failed to get search context." ); ret = -ENOMEM ; - goto undo_alloc; + goto undo_alloc_noctx; } ret =ntfs_attr_lookup (mft_ni->type, mft_ni->name, mft_ni->name_len,CASE_SENSITIVE , rl[1 ].vcn,NULL ,0 , ctx);
@@ -1988,8 +1988,8 @@ undo_alloc: "context.%s", es);NVolSetErrors (vol); } -if (ctx) -ntfs_attr_put_search_ctx (ctx); +ntfs_attr_put_search_ctx (ctx); +undo_alloc_noctx:if (!IS_ERR (mrec))unmap_mft_record (mft_ni);up_write (&mft_ni->runlist.lock);
Signature · 1 line
1.7.10.4