All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] btrfs: push btrfs_grab_fs_root into btrfs_get_fs_root
@ 2020-05-23 17:57 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2020-05-23 17:57 UTC (permalink / raw)
  To: josef; +Cc: linux-btrfs

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-23 17:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 17:57 [bug report] btrfs: push btrfs_grab_fs_root into btrfs_get_fs_root Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.