Skip to content

Commit b97f920

Browse files
ukernelchrismason-xx
authored andcommitted
Btrfs: Fix typo and memory leak in extent-tree.c
This patch fixes a typo in update_block_group and memory leak in btrfs_free_block_groups. Signed-off-by: Chris Mason <[email protected]>
1 parent 179e29e commit b97f920

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/btrfs/extent-tree.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,16 +588,15 @@ static int update_block_group(struct btrfs_trans_handle *trans,
588588
old_val < (cache->key.offset >> 1)) {
589589
int bit_to_clear;
590590
int bit_to_set;
591-
592591
cache->data = data;
593592
if (data) {
594-
bit_to_clear = BLOCK_GROUP_DATA;
595-
bit_to_set = BLOCK_GROUP_METADATA;
593+
bit_to_clear = BLOCK_GROUP_METADATA;
594+
bit_to_set = BLOCK_GROUP_DATA;
596595
cache->item.flags |=
597596
BTRFS_BLOCK_GROUP_DATA;
598597
} else {
599-
bit_to_clear = BLOCK_GROUP_METADATA;
600-
bit_to_set = BLOCK_GROUP_DATA;
598+
bit_to_clear = BLOCK_GROUP_DATA;
599+
bit_to_set = BLOCK_GROUP_METADATA;
601600
cache->item.flags &=
602601
~BTRFS_BLOCK_GROUP_DATA;
603602
}
@@ -1459,13 +1458,16 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
14591458
{
14601459
u64 start;
14611460
u64 end;
1461+
u64 ptr;
14621462
int ret;
1463-
14641463
while(1) {
14651464
ret = find_first_extent_bit(&info->block_group_cache, 0,
14661465
&start, &end, (unsigned int)-1);
14671466
if (ret)
14681467
break;
1468+
ret = get_state_private(&info->block_group_cache, start, &ptr);
1469+
if (!ret)
1470+
kfree((void *)(unsigned long)ptr);
14691471
clear_extent_bits(&info->block_group_cache, start,
14701472
end, (unsigned int)-1, GFP_NOFS);
14711473
}

0 commit comments

Comments
 (0)