We want to use this for dropping all roots, and in some error cases we
may not have a root, so handle this to make the cleanup code easier.
Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
fs/btrfs/disk-io.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 5b38558e164d..1685dd2cf7ab 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -95,6 +95,9 @@ static inline struct btrfs_root *btrfs_grab_fs_root(struct btrfs_root *root)
static inline void btrfs_put_fs_root(struct btrfs_root *root)
{
+ if (!root)
+ return;
+
if (refcount_dec_and_test(&root->refs))
kfree(root);
}
--
2.23.0