Commit 95c85fb
btrfs: avoid double put of block group when emptying cluster
It's wrong calling btrfs_put_block_group in
__btrfs_return_cluster_to_free_space if the block group passed is
different than the block group the cluster represents. As this means the
cluster doesn't have a reference to the passed block group. This results
in double put and a use-after-free bug.
Fix this by simply bailing if the block group we passed in does not
match the block group on the cluster.
Fixes: fa9c0d7 ("Btrfs: rework allocation clustering")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>1 parent 3660d0b commit 95c85fb
1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2801 | 2801 | | |
2802 | 2802 | | |
2803 | 2803 | | |
2804 | | - | |
2805 | | - | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
2806 | 2808 | | |
2807 | 2809 | | |
2808 | 2810 | | |
| |||
2840 | 2842 | | |
2841 | 2843 | | |
2842 | 2844 | | |
2843 | | - | |
2844 | | - | |
2845 | 2845 | | |
2846 | 2846 | | |
2847 | 2847 | | |
| |||
0 commit comments