mirror of https://gitee.com/openkylin/linux.git
btrfs: tests: don't leak fs_info in extent_io bitmap tests
The fs_info is not freed at the end of the function and leaks. The function is called twice so there can be up to 2x sizeof(struct btrfs_fs_info) of leaked memory. Fortunatelly this affects only testing builds, the size could be 16k with several debugging features enabled. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d46a05edac
commit
d33d105b85
|
@ -378,8 +378,8 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info;
|
struct btrfs_fs_info *fs_info;
|
||||||
unsigned long len;
|
unsigned long len;
|
||||||
unsigned long *bitmap;
|
unsigned long *bitmap = NULL;
|
||||||
struct extent_buffer *eb;
|
struct extent_buffer *eb = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
test_msg("running extent buffer bitmap tests");
|
test_msg("running extent buffer bitmap tests");
|
||||||
|
@ -400,14 +400,15 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
|
||||||
bitmap = kmalloc(len, GFP_KERNEL);
|
bitmap = kmalloc(len, GFP_KERNEL);
|
||||||
if (!bitmap) {
|
if (!bitmap) {
|
||||||
test_err("couldn't allocate test bitmap");
|
test_err("couldn't allocate test bitmap");
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
eb = __alloc_dummy_extent_buffer(fs_info, 0, len);
|
eb = __alloc_dummy_extent_buffer(fs_info, 0, len);
|
||||||
if (!eb) {
|
if (!eb) {
|
||||||
test_err("couldn't allocate test extent buffer");
|
test_err("couldn't allocate test extent buffer");
|
||||||
kfree(bitmap);
|
ret = -ENOMEM;
|
||||||
return -ENOMEM;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = __test_eb_bitmaps(bitmap, eb, len);
|
ret = __test_eb_bitmaps(bitmap, eb, len);
|
||||||
|
@ -419,14 +420,15 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
|
||||||
eb = __alloc_dummy_extent_buffer(NULL, nodesize / 2, len);
|
eb = __alloc_dummy_extent_buffer(NULL, nodesize / 2, len);
|
||||||
if (!eb) {
|
if (!eb) {
|
||||||
test_err("couldn't allocate test extent buffer");
|
test_err("couldn't allocate test extent buffer");
|
||||||
kfree(bitmap);
|
ret = -ENOMEM;
|
||||||
return -ENOMEM;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = __test_eb_bitmaps(bitmap, eb, len);
|
ret = __test_eb_bitmaps(bitmap, eb, len);
|
||||||
out:
|
out:
|
||||||
free_extent_buffer(eb);
|
free_extent_buffer(eb);
|
||||||
kfree(bitmap);
|
kfree(bitmap);
|
||||||
|
btrfs_free_dummy_fs_info(fs_info);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue