Skip to contentSkip to conversation

btrfs: fix root leak if its reloc root is unexpected in merge_reloc_roots()

PATCH New Dmitriy Okunev 1 participant 1 message Aug 17

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix root leak if its reloc root is unexpected in merge_reloc_roots()

From: Filipe Manana <[email protected]>

commit ce6050bafb4e33377dc17fcc357736bfc351180c upstream.

If we have an unexpected reloc_root for our root, we jump to the out label but never drop the reference we obtained for root, resulting in a leak. Add a missing btrfs_put_root() call.

Fixes 24213fa46c70 ("btrfs: do proper error handling in merge_reloc_roots")
---
 fs/btrfs/relocation.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/relocation.c +1 -0
index 43e8c331168e..d2a1323e8b10 100644
@@ -1956,6 +1956,7 @@ void merge_reloc_roots(struct reloc_control *rc)
 				 * corruption, e.g. bad reloc tree key offset.
 				 */
 				ret = -EINVAL;
+				btrfs_put_root(root);
 				goto out;
 			}
 			ret = merge_reloc_root(rc, root);
Signature · 1 line
2.53.0