Skip to contentSkip to conversation

fs/ntfs3: inconsistent NULL checking in mi_read()

bug report Dan Carpenter 1 participant 1 message Aug 24, 2021 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

Hello Konstantin Komarov,

This is a semi-automatic email about new static checker warnings.

The patch 4342306f0f0d: "fs/ntfs3: Add file operations and implementation" from Aug 13, 2021, leads to the following Smatch complaint:

fs/ntfs3/record.c:158 mi_read()
error: we previously assumed 'mft_ni' could be null (see line 130)

fs/ntfs3/record.c
129 struct ntfs_inode *mft_ni = sbi->mft.ni;

   130		struct runs_tree *run = mft_ni ? &mft_ni->file.run : NULL;
                                        ^^^^^^

Check for NULL

131 struct rw_semaphore *rw_lock = NULL;
132
133 if (is_mounted(sbi)) {
134 if (!is_mft) {
135 rw_lock = &mft_ni->file.run_lock;
136 down_read(rw_lock);
137 }
138 }
139
140 err = ntfs_read_bh(sbi, run, vbo, &rec->rhdr, bpr, &mi->nb);
141 if (rw_lock)
142 up_read(rw_lock);
143 if (!err)
144 goto ok;
145
146 if (err == -E_NTFS_FIXUP) {
147 mi->dirty = true;
148 goto ok;
149 }
150
151 if (err != -ENOENT)
152 goto out;
153
154 if (rw_lock) {
155 ni_lock(mft_ni);
156 down_write(rw_lock);
157 }
158 err = attr_load_runs_vcn(mft_ni, ATTR_DATA, NULL, 0, &mft_ni->file.run,

                                         ^^^^^^                       ^^^^^^^^^^^^^^^^

Unchecked dereference inside function call.

   159					 vbo >> sbi->cluster_bits);
   160		if (rw_lock) {

regards,
dan carpenter