Skip to content

Commit

Permalink
Btrfs: fix subvol_sem leak in btrfs_rename()
Browse files Browse the repository at this point in the history
btrfs_rename() does not release the subvol_sem if the transaction failed to start.

Signed-off-by: Johann Lombardi <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
Johann Lombardi authored and chrismason-xx committed Apr 5, 2011
1 parent fe3f566 commit b44c59a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
trans = btrfs_start_transaction(root, 20);
if (IS_ERR(trans))
return PTR_ERR(trans);
if (IS_ERR(trans)) {
ret = PTR_ERR(trans);
goto out_notrans;
}

btrfs_set_trans_block_group(trans, new_dir);

Expand Down Expand Up @@ -7062,7 +7064,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
}
out_fail:
btrfs_end_transaction_throttle(trans, root);

out_notrans:
if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)
up_read(&root->fs_info->subvol_sem);

Expand Down

0 comments on commit b44c59a

Please sign in to comment.