Skip to content

Commit c990161

Browse files
committed
Btrfs: fix inode leak on failure to setup whiteout inode in rename
If we failed to fully setup the whiteout inode during a rename operation with the whiteout flag, we ended up leaking the inode, not decrementing its link count nor removing all its items from the fs/subvol tree. Signed-off-by: Filipe Manana <[email protected]>
1 parent cdd1fed commit c990161

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/btrfs/inode.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9612,21 +9612,21 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
96129612
ret = btrfs_init_inode_security(trans, inode, dir,
96139613
&dentry->d_name);
96149614
if (ret)
9615-
return ret;
9615+
goto out;
96169616

96179617
ret = btrfs_add_nondir(trans, dir, dentry,
96189618
inode, 0, index);
96199619
if (ret)
9620-
return ret;
9620+
goto out;
96219621

96229622
ret = btrfs_update_inode(trans, root, inode);
9623-
if (ret)
9624-
return ret;
9625-
9623+
out:
96269624
unlock_new_inode(inode);
9625+
if (ret)
9626+
inode_dec_link_count(inode);
96279627
iput(inode);
96289628

9629-
return 0;
9629+
return ret;
96309630
}
96319631

96329632
static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,

0 commit comments

Comments
 (0)