]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs: Fix null pointer dereference
authorEthan Tidmore <ethantidmore06@gmail.com>
Wed, 25 Feb 2026 22:24:53 +0000 (16:24 -0600)
committerNamjae Jeon <linkinjeon@kernel.org>
Thu, 26 Feb 2026 09:26:00 +0000 (18:26 +0900)
The variable ctx can be null and once confirmed to be null in its error
path goes to label err_out. Once there it can be immediately dereferenced
by the function ntfs_attr_put_search_ctx() which has no null pointer check.

Detected by Smatch:
fs/ntfs/ea.c:687 ntfs_new_attr_flags() error:
we previously assumed 'ctx' could be null (see line 577)

Add null pointer check before running  ntfs_attr_put_search_ctx() in
error path.

Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/ea.c

index 82ad9b61ec64b2138782f4168c75222454723c5a..b2b0a9a043a9e755de9f6a9afec22218aee45fba 100644 (file)
@@ -684,7 +684,8 @@ out:
        a->flags = new_aflags;
        mark_mft_record_dirty(ctx->ntfs_ino);
 err_out:
-       ntfs_attr_put_search_ctx(ctx);
+       if (ctx)
+               ntfs_attr_put_search_ctx(ctx);
        unmap_mft_record(ni);
        return err;
 }