From: Dan Carpenter <dan.carpenter@oracle.com>
To: almaz.alexandrovich@paragon-software.com
Cc: ntfs3@lists.linux.dev
Subject: [bug report] fs/ntfs3: inconsistent NULL checking in do_action()
Date: Wed, 25 Aug 2021 11:37:33 +0300 [thread overview]
Message-ID: <20210825083732.GA23148@kili> (raw)
Hello Konstantin Komarov,
This is a semi-automatic email about new static checker warnings.
The patch b46acd6a6a62: "fs/ntfs3: Add NTFS journal" from Aug 13,
2021, leads to the following Smatch complaint:
fs/ntfs3/fslog.c:3141 do_action()
warn: variable dereferenced before check 'mi' (see line 3102)
fs/ntfs3/fslog.c
3101 }
3102 rec = mi->mrec;
^^^^^^^^
Dereferenced
3103
3104 if (op == DeallocateFileRecordSegment)
3105 goto skip_load_parent;
3106
3107 if (InitializeFileRecordSegment != op) {
3108 if (rec->rhdr.sign == NTFS_BAAD_SIGNATURE)
3109 goto dirty_vol;
3110 if (!check_lsn(&rec->rhdr, rlsn))
3111 goto out;
3112 if (!check_file_record(rec, NULL, sbi))
3113 goto dirty_vol;
3114 attr = Add2Ptr(rec, roff);
3115 }
3116
3117 if (is_rec_base(rec) || InitializeFileRecordSegment == op) {
3118 rno_base = rno;
3119 goto skip_load_parent;
3120 }
3121
3122 rno_base = ino_get(&rec->parent_ref);
3123 inode_parent = ntfs_iget5(sbi->sb, &rec->parent_ref, NULL);
3124 if (IS_ERR(inode_parent))
3125 goto skip_load_parent;
3126
3127 if (is_bad_inode(inode_parent)) {
3128 iput(inode_parent);
3129 goto skip_load_parent;
3130 }
3131
3132 if (ni_load_mi_ex(ntfs_i(inode_parent), rno, &mi2_child)) {
3133 iput(inode_parent);
3134 } else {
3135 if (mi2_child->mrec != mi->mrec)
^^^^^^^^
Dereferenced.
3136 memcpy(mi2_child->mrec, mi->mrec,
3137 sbi->record_size);
3138
3139 if (inode)
3140 iput(inode);
3141 else if (mi)
^^
Checked too late.
3142 mi_put(mi);
3143
regards,
dan carpenter
reply other threads:[~2021-08-25 8:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210825083732.GA23148@kili \
--to=dan.carpenter@oracle.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=ntfs3@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox