Commit acbee9af authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

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: 14605409 ("btrfs: initial fsverity support")
Fixes: 70524253 ("btrfs: verity metadata orphan items")
Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent bbc9a6eb
...@@ -451,7 +451,7 @@ static int del_orphan(struct btrfs_trans_handle *trans, struct btrfs_inode *inod ...@@ -451,7 +451,7 @@ static int del_orphan(struct btrfs_trans_handle *trans, struct btrfs_inode *inod
*/ */
static int rollback_verity(struct btrfs_inode *inode) static int rollback_verity(struct btrfs_inode *inode)
{ {
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans = NULL;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
int ret; int ret;
...@@ -473,6 +473,7 @@ static int rollback_verity(struct btrfs_inode *inode) ...@@ -473,6 +473,7 @@ static int rollback_verity(struct btrfs_inode *inode)
trans = btrfs_start_transaction(root, 2); trans = btrfs_start_transaction(root, 2);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
ret = PTR_ERR(trans); ret = PTR_ERR(trans);
trans = NULL;
btrfs_handle_fs_error(root->fs_info, ret, btrfs_handle_fs_error(root->fs_info, ret,
"failed to start transaction in verity rollback %llu", "failed to start transaction in verity rollback %llu",
(u64)inode->vfs_inode.i_ino); (u64)inode->vfs_inode.i_ino);
...@@ -490,8 +491,9 @@ static int rollback_verity(struct btrfs_inode *inode) ...@@ -490,8 +491,9 @@ static int rollback_verity(struct btrfs_inode *inode)
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
btrfs_end_transaction(trans);
out: out:
if (trans)
btrfs_end_transaction(trans);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment