Message ID | 20250321153238.918616-1-Ilia.Gavrilov@infotecs.ru (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [5.10] btrfs: have proper error handling in btrfs_init_reloc_root | expand |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 5b921e6ed94e..b0d34879e267 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -878,9 +878,15 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, reloc_root = create_reloc_root(trans, root, root->root_key.objectid); if (clear_rsv) trans->block_rsv = rsv; + if (IS_ERR(reloc_root)) + return PTR_ERR(reloc_root); ret = __add_reloc_root(reloc_root); - BUG_ON(ret < 0); + if (ret) { + /* Pairs with create_reloc_root */ + btrfs_put_root(reloc_root); + return ret; + } root->reloc_root = btrfs_grab_root(reloc_root); return 0; }