All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] fs/ntfs3: inconsistent NULL checking in mi_read()
@ 2021-08-24 11:39 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-08-24 11:39 UTC (permalink / raw)
  To: almaz.alexandrovich; +Cc: ntfs3

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-24 11:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 11:39 [bug report] fs/ntfs3: inconsistent NULL checking in mi_read() Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.