Skip to content

Commit acbee9a

Browse files
fdmananakdave
authored andcommitted
btrfs: fix transaction handle leak after verity rollback failure
During a verity rollback, if we fail to update the inode or delete the orphan, we abort the transaction and return without releasing our transaction handle. Fix that by releasing the handle. Fixes: 1460540 ("btrfs: initial fsverity support") Fixes: 7052425 ("btrfs: verity metadata orphan items") Reviewed-by: Boris Burkov <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent bbc9a6e commit acbee9a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/btrfs/verity.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int del_orphan(struct btrfs_trans_handle *trans, struct btrfs_inode *inod
451451
*/
452452
static int rollback_verity(struct btrfs_inode *inode)
453453
{
454-
struct btrfs_trans_handle *trans;
454+
struct btrfs_trans_handle *trans = NULL;
455455
struct btrfs_root *root = inode->root;
456456
int ret;
457457

@@ -473,6 +473,7 @@ static int rollback_verity(struct btrfs_inode *inode)
473473
trans = btrfs_start_transaction(root, 2);
474474
if (IS_ERR(trans)) {
475475
ret = PTR_ERR(trans);
476+
trans = NULL;
476477
btrfs_handle_fs_error(root->fs_info, ret,
477478
"failed to start transaction in verity rollback %llu",
478479
(u64)inode->vfs_inode.i_ino);
@@ -490,8 +491,9 @@ static int rollback_verity(struct btrfs_inode *inode)
490491
btrfs_abort_transaction(trans, ret);
491492
goto out;
492493
}
493-
btrfs_end_transaction(trans);
494494
out:
495+
if (trans)
496+
btrfs_end_transaction(trans);
495497
return ret;
496498
}
497499

0 commit comments

Comments
 (0)