Commit b44c59a8 authored by Johann Lombardi's avatar Johann Lombardi Committed by Chris Mason

Btrfs: fix subvol_sem leak in btrfs_rename()

btrfs_rename() does not release the subvol_sem if the transaction failed to start.
Signed-off-by: default avatarJohann Lombardi <johann@whamcloud.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent fe3f566c
...@@ -6961,8 +6961,10 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -6961,8 +6961,10 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
* should cover the worst case number of items we'll modify. * should cover the worst case number of items we'll modify.
*/ */
trans = btrfs_start_transaction(root, 20); trans = btrfs_start_transaction(root, 20);
if (IS_ERR(trans)) if (IS_ERR(trans)) {
return PTR_ERR(trans); ret = PTR_ERR(trans);
goto out_notrans;
}
btrfs_set_trans_block_group(trans, new_dir); btrfs_set_trans_block_group(trans, new_dir);
...@@ -7062,7 +7064,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -7062,7 +7064,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
} }
out_fail: out_fail:
btrfs_end_transaction_throttle(trans, root); btrfs_end_transaction_throttle(trans, root);
out_notrans:
if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)
up_read(&root->fs_info->subvol_sem); up_read(&root->fs_info->subvol_sem);
......
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