diff mbox series

[09/44] btrfs: handle NULL roots in btrfs_put_fs_root()

Message ID 20191206144538.168112-10-josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Cleanup how we handle root refs, part 1 | expand

Commit Message

Josef Bacik Dec. 6, 2019, 2:45 p.m. UTC
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@toxicpanda.com>
---
 fs/btrfs/disk-io.h | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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);
 }