Skip to content

Commit c67cda1

Browse files
ukernelchrismason-xx
authored andcommitted
Btrfs: Fix extent_map leak in extent_bmap
Signed-off-by: Chris Mason <[email protected]>
1 parent 44ec0b7 commit c67cda1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/btrfs/extent_map.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,7 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
19241924
struct inode *inode = mapping->host;
19251925
u64 start = iblock << inode->i_blkbits;
19261926
u64 end = start + (1 << inode->i_blkbits) - 1;
1927+
sector_t sector = 0;
19271928
struct extent_map *em;
19281929

19291930
em = get_extent(inode, NULL, 0, start, end, 0);
@@ -1932,9 +1933,12 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
19321933

19331934
if (em->block_start == EXTENT_MAP_INLINE ||
19341935
em->block_start == EXTENT_MAP_HOLE)
1935-
return 0;
1936+
goto out;
19361937

1937-
return (em->block_start + start - em->start) >> inode->i_blkbits;
1938+
sector = (em->block_start + start - em->start) >> inode->i_blkbits;
1939+
out:
1940+
free_extent_map(em);
1941+
return sector;
19381942
}
19391943

19401944
static int add_lru(struct extent_map_tree *tree, struct extent_buffer *eb)

0 commit comments

Comments
 (0)