From: Filipe Manana Date: Mon, 3 Apr 2017 14:57:17 +0000 (+0100) Subject: Btrfs: fix extent map leak during fallocate error path X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=be2d253cc98244765323a7c94cc1ac5cd5a17072;p=openwrt%2Fstaging%2Fblogic.git Btrfs: fix extent map leak during fallocate error path 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: Filipe Manana Reviewed-by: David Sterba --- diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 48dfb8e4baf2..56304c400db5 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2856,8 +2856,10 @@ static long btrfs_fallocate(struct file *file, int mode, } ret = btrfs_qgroup_reserve_data(inode, cur_offset, last_byte - cur_offset); - if (ret < 0) + if (ret < 0) { + free_extent_map(em); break; + } } else { /* * Do not need to reserve unwritten extent for this