If we fail to update the inode or delete the orphan item we leak the inode
since we update its refcount with the ihold() call to account for the
d_instantiate() call which never happens in case we fail those steps. Fix
this by setting 'drop_inode' to true in case we fail those steps.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) {
btrfs_abort_transaction(trans, ret);
+ drop_inode = 1;
goto fail;
}
if (inode->i_nlink == 1) {
ret = btrfs_orphan_del(trans, BTRFS_I(inode));
if (ret) {
btrfs_abort_transaction(trans, ret);
+ drop_inode = 1;
goto fail;
}
}