Commit c67cda17 authored by Yan's avatar Yan Committed by Chris Mason

Btrfs: Fix extent_map leak in extent_bmap

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 44ec0b71
...@@ -1924,6 +1924,7 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock, ...@@ -1924,6 +1924,7 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
u64 start = iblock << inode->i_blkbits; u64 start = iblock << inode->i_blkbits;
u64 end = start + (1 << inode->i_blkbits) - 1; u64 end = start + (1 << inode->i_blkbits) - 1;
sector_t sector = 0;
struct extent_map *em; struct extent_map *em;
em = get_extent(inode, NULL, 0, start, end, 0); em = get_extent(inode, NULL, 0, start, end, 0);
...@@ -1932,9 +1933,12 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock, ...@@ -1932,9 +1933,12 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
if (em->block_start == EXTENT_MAP_INLINE || if (em->block_start == EXTENT_MAP_INLINE ||
em->block_start == EXTENT_MAP_HOLE) em->block_start == EXTENT_MAP_HOLE)
return 0; goto out;
return (em->block_start + start - em->start) >> inode->i_blkbits; sector = (em->block_start + start - em->start) >> inode->i_blkbits;
out:
free_extent_map(em);
return sector;
} }
static int add_lru(struct extent_map_tree *tree, struct extent_buffer *eb) static int add_lru(struct extent_map_tree *tree, struct extent_buffer *eb)
......
Markdown is supported
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