public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: nborisov@suse.com
Cc: linux-btrfs@vger.kernel.org
Subject: [bug report] btrfs: clean BTRFS_I usage in btrfs_destroy_inode
Date: Tue, 22 Sep 2020 14:01:18 +0300	[thread overview]
Message-ID: <20200922110118.GA1297350@mwanda> (raw)

Hello Nikolay Borisov,

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

The patch ab46388723da: "btrfs: clean BTRFS_I usage in
btrfs_destroy_inode" from Sep 18, 2020, leads to the following Smatch
complaint:

    fs/btrfs/inode.c:8668 btrfs_destroy_inode()
    warn: variable dereferenced before check 'root' (see line 8651)

fs/btrfs/inode.c
  8650		struct btrfs_root *root = inode->root;
  8651		struct btrfs_fs_info *fs_info = root->fs_info;
                                                ^^^^^^^^^^^^^
New dereference

  8652	
  8653		WARN_ON(!hlist_empty(&vfs_inode->i_dentry));
  8654		WARN_ON(vfs_inode->i_data.nrpages);
  8655		WARN_ON(inode->block_rsv.reserved);
  8656		WARN_ON(inode->block_rsv.size);
  8657		WARN_ON(inode->outstanding_extents);
  8658		WARN_ON(inode->delalloc_bytes);
  8659		WARN_ON(inode->new_delalloc_bytes);
  8660		WARN_ON(inode->csum_bytes);
  8661		WARN_ON(inode->defrag_bytes);
  8662	
  8663		/*
  8664		 * This can happen where we create an inode, but somebody else also
  8665		 * created the same inode and we need to destroy the one we already
  8666		 * created.
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
But "root" can be NULL.

  8667		 */
  8668		if (!root)
                    ^^^^^
  8669			return;
  8670	

regards,
dan carpenter

             reply	other threads:[~2020-09-22 11:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 11:01 Dan Carpenter [this message]
2020-09-22 14:47 ` [bug report] btrfs: clean BTRFS_I usage in btrfs_destroy_inode David Sterba

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=20200922110118.GA1297350@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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