Linux-BTRFS Archive on
 help / color / Atom feed
From: Dan Carpenter <>
Subject: [bug report] btrfs: push btrfs_grab_fs_root into btrfs_get_fs_root
Date: Sat, 23 May 2020 20:57:27 +0300
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

  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;
  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:

dan carpenter

                 reply index

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200523175727.GA105997@mwanda \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-BTRFS Archive on

Archives are clonable:
	git clone --mirror linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ \
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone