Commit 373c3b80 authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by David Sterba
Browse files

btrfs: don't leak extent_map in btrfs_get_io_geometry()

btrfs_get_io_geometry() calls btrfs_get_chunk_map() to acquire a reference
on a extent_map, but on normal operation it does not drop this reference

This leads to excessive kmemleak reports.

Always call free_extent_map(), not just in the error case.

Fixes: 5f141126

 ("btrfs: Introduce btrfs_io_geometry infrastructure")
Reviewed-by: default avatarNikolay Borisov <>
Signed-off-by: default avatarJohannes Thumshirn <>
Reviewed-by: default avatarDavid Sterba <>
Signed-off-by: default avatarDavid Sterba <>
parent bfcea1c6
......@@ -5941,6 +5941,7 @@ int btrfs_get_io_geometry(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
u64 stripe_len;
u64 raid56_full_stripe_start = (u64)-1;
int data_stripes;
int ret = 0;
......@@ -5961,8 +5962,8 @@ int btrfs_get_io_geometry(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
"stripe math has gone wrong, stripe_offset=%llu offset=%llu start=%llu logical=%llu stripe_len=%llu",
stripe_offset, offset, em->start, logical, stripe_len);
return -EINVAL;
ret = -EINVAL;
goto out;
/* stripe_offset is the offset of this block in its stripe */
......@@ -6009,7 +6010,10 @@ int btrfs_get_io_geometry(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
io_geom->stripe_offset = stripe_offset;
io_geom->raid56_stripe_offset = raid56_full_stripe_start;
return 0;
/* once for us */
return ret;
static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment