Commit dfe9db1d authored by Filipe Manana's avatar Filipe Manana Committed by Greg Kroah-Hartman

Btrfs: fix extent map leak during fallocate error path


[ Upstream commit be2d253c ]

If the call to btrfs_qgroup_reserve_data() failed, we were leaking an
extent map structure. The failure can happen either due to an -ENOMEM
condition or, when quotas are enabled, due to -EDQUOT for example.
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7016b20c
...@@ -2817,8 +2817,10 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -2817,8 +2817,10 @@ static long btrfs_fallocate(struct file *file, int mode,
} }
ret = btrfs_qgroup_reserve_data(inode, cur_offset, ret = btrfs_qgroup_reserve_data(inode, cur_offset,
last_byte - cur_offset); last_byte - cur_offset);
if (ret < 0) if (ret < 0) {
free_extent_map(em);
break; break;
}
} else { } else {
/* /*
* Do not need to reserve unwritten extent for this * Do not need to reserve unwritten extent for this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment