Skip to content

Commit be2d253

Browse files
committed
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 <[email protected]> Reviewed-by: David Sterba <[email protected]>
1 parent 1c81ba2 commit be2d253

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/btrfs/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2856,8 +2856,10 @@ static long btrfs_fallocate(struct file *file, int mode,
28562856
}
28572857
ret = btrfs_qgroup_reserve_data(inode, cur_offset,
28582858
last_byte - cur_offset);
2859-
if (ret < 0)
2859+
if (ret < 0) {
2860+
free_extent_map(em);
28602861
break;
2862+
}
28612863
} else {
28622864
/*
28632865
* Do not need to reserve unwritten extent for this

0 commit comments

Comments
 (0)