Commit 0b0d369f authored by Filipe Manana's avatar Filipe Manana Committed by Khalid Elmously

Btrfs: fix extent map leak during fallocate error path

BugLink: https://bugs.launchpad.net/bugs/1822579

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>
(backported from commit be2d253c)
Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
Acked-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 4540b78b
......@@ -2763,8 +2763,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;
}
}
free_extent_map(em);
cur_offset = last_byte;
......
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