diff options
author | Filipe Manana <fdmanana@suse.com> | 2016-05-05 03:41:57 +0300 |
---|---|---|
committer | Filipe Manana <fdmanana@suse.com> | 2016-05-13 03:59:23 +0300 |
commit | c990161888f387db136856337c237aa8d5003292 (patch) | |
tree | 397eb09cf725f25d7c6a36efd411e88da148e7f7 /fs/btrfs | |
parent | cdd1fedf8261cd7a73c0596298902ff4f0f04492 (diff) | |
download | linux-c990161888f387db136856337c237aa8d5003292.tar.xz |
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 <fdmanana@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/inode.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 452cfefbf4b8..98c119b02916 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9612,21 +9612,21 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans, ret = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); if (ret) - return ret; + goto out; ret = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); if (ret) - return ret; + goto out; ret = btrfs_update_inode(trans, root, inode); - if (ret) - return ret; - +out: unlock_new_inode(inode); + if (ret) + inode_dec_link_count(inode); iput(inode); - return 0; + return ret; } static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, |