From: Dan Carpenter <dan.carpenter@oracle.com>
To: josef@toxicpanda.com
Cc: linux-btrfs@vger.kernel.org
Subject: [bug report] btrfs: push btrfs_grab_fs_root into btrfs_get_fs_root
Date: Sat, 23 May 2020 20:57:27 +0300 [thread overview]
Message-ID: <20200523175727.GA105997@mwanda> (raw)
Hello Josef Bacik,
The patch bc44d7c4b2b1: "btrfs: push btrfs_grab_fs_root into
btrfs_get_fs_root" from Jan 24, 2020, leads to the following static
checker warning:
fs/btrfs/backref.c:565 resolve_indirect_ref()
warn: 'root' can also be NULL
fs/btrfs/backref.c
1537 struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
1538 u64 objectid, bool check_ref)
1539 {
1540 struct btrfs_root *root;
1541 struct btrfs_path *path;
1542 struct btrfs_key key;
1543 int ret;
1544
1545 if (objectid == BTRFS_ROOT_TREE_OBJECTID)
1546 return btrfs_grab_root(fs_info->tree_root);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1547 if (objectid == BTRFS_EXTENT_TREE_OBJECTID)
1548 return btrfs_grab_root(fs_info->extent_root);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
These return NULL on error and it leads to an OOps in the caller.
1549 if (objectid == BTRFS_CHUNK_TREE_OBJECTID)
1550 return btrfs_grab_root(fs_info->chunk_root);
1551 if (objectid == BTRFS_DEV_TREE_OBJECTID)
1552 return btrfs_grab_root(fs_info->dev_root);
1553 if (objectid == BTRFS_CSUM_TREE_OBJECTID)
1554 return btrfs_grab_root(fs_info->csum_root);
1555 if (objectid == BTRFS_QUOTA_TREE_OBJECTID)
1556 return btrfs_grab_root(fs_info->quota_root) ?
1557 fs_info->quota_root : ERR_PTR(-ENOENT);
It should probably return ERR_PTR(-ENOENT).
1558 if (objectid == BTRFS_UUID_TREE_OBJECTID)
1559 return btrfs_grab_root(fs_info->uuid_root) ?
1560 fs_info->uuid_root : ERR_PTR(-ENOENT);
1561 if (objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
1562 return btrfs_grab_root(fs_info->free_space_root) ?
1563 fs_info->free_space_root : ERR_PTR(-ENOENT);
1564 again:
regards,
dan carpenter
reply other threads:[~2020-05-23 17:57 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=20200523175727.GA105997@mwanda \
--to=dan.carpenter@oracle.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).