public inbox for ntfs3@lists.linux.dev
 help / color / mirror / Atom feed
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 mi_read()
Date: Tue, 24 Aug 2021 14:39:46 +0300	[thread overview]
Message-ID: <20210824113946.GC31143@kili> (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

                 reply	other threads:[~2021-08-24 11:40 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=20210824113946.GC31143@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