4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Filipe Manana <fdman...@suse.com>


[ Upstream commit be2d253cc98244765323a7c94cc1ac5cd5a17072 ]

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 <fdman...@suse.com>
Reviewed-by: David Sterba <dste...@suse.com>
Signed-off-by: Sasha Levin <alexander.le...@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 fs/btrfs/file.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2817,8 +2817,10 @@ static long btrfs_fallocate(struct file
                        }
                        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


Reply via email to