Skip to content

Commit

Permalink
Btrfs: fix extent map leak during fallocate error path
Browse files Browse the repository at this point in the history
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 <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Filipe Manana committed Apr 26, 2017
1 parent 1c81ba2 commit be2d253
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be2d253

Please sign in to comment.