Skip to content

Commit b44c59a

Browse files
Johann Lombardichrismason-xx
authored andcommitted
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: Johann Lombardi <johann@whamcloud.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent fe3f566 commit b44c59a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fs/btrfs/inode.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6961,8 +6961,10 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
69616961
* should cover the worst case number of items we'll modify.
69626962
*/
69636963
trans = btrfs_start_transaction(root, 20);
6964-
if (IS_ERR(trans))
6965-
return PTR_ERR(trans);
6964+
if (IS_ERR(trans)) {
6965+
ret = PTR_ERR(trans);
6966+
goto out_notrans;
6967+
}
69666968

69676969
btrfs_set_trans_block_group(trans, new_dir);
69686970

@@ -7062,7 +7064,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
70627064
}
70637065
out_fail:
70647066
btrfs_end_transaction_throttle(trans, root);
7065-
7067+
out_notrans:
70667068
if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)
70677069
up_read(&root->fs_info->subvol_sem);
70687070

0 commit comments

Comments
 (0)