Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: <dan.carpenter@oracle.com>
To: <amir73il@gmail.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: [bug report] fsnotify: pass dir and inode arguments to fsnotify()
Date: Thu, 30 Jul 2020 14:13:39 +0300	[thread overview]
Message-ID: <20200730111339.GA54272@mwanda> (raw)

Hello Amir Goldstein,

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

The patch 40a100d3adc1: "fsnotify: pass dir and inode arguments to
fsnotify()" from Jul 22, 2020, leads to the following Smatch
complaint:

    fs/notify/fsnotify.c:460 fsnotify()
    warn: variable dereferenced before check 'inode' (see line 449)

fs/notify/fsnotify.c
   448		}
   449		sb = inode->i_sb;
                     ^^^^^^^^^^^
New dreference.

   450	
   451		/*
   452		 * Optimization: srcu_read_lock() has a memory barrier which can
   453		 * be expensive.  It protects walking the *_fsnotify_marks lists.
   454		 * However, if we do not walk the lists, we do not have to do
   455		 * SRCU because we have no references to any objects and do not
   456		 * need SRCU to keep them "alive".
   457		 */
   458		if (!sb->s_fsnotify_marks &&
   459		    (!mnt || !mnt->mnt_fsnotify_marks) &&
   460		    (!inode || !inode->i_fsnotify_marks) &&
                     ^^^^^^
Check too late.  Presumably this check can be removed?

   461		    (!child || !child->i_fsnotify_marks))
   462			return 0;

regards,
dan carpenter

             reply	other threads:[~2020-07-30 11:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 11:13 dan.carpenter [this message]
2020-07-30 11:55 ` Amir Goldstein
2020-07-30 19:25   ` Jan Kara

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=20200730111339.GA54272@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --subject='Re: [bug report] fsnotify: pass dir and inode arguments to fsnotify()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).