Skip to content

Commit 8a565ec

Browse files
fdmananakdave
authored andcommitted
btrfs: fix extent map leak in unexpected scenario at unpin_extent_cache()
At unpin_extent_cache() if we happen to find an extent map with an unexpected start offset, we jump to the 'out' label and never release the reference we added to the extent map through the call to lookup_extent_mapping(), therefore resulting in a leak. So fix this by moving the free_extent_map() under the 'out' label. Fixes: c03c89f ("btrfs: handle errors returned from unpin_extent_cache()") Reviewed-by: Qu Wenruo <[email protected]> Reviewed-by: Anand Jain <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 9f7eb84 commit 8a565ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/extent_map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)
340340
em->mod_len = em->len;
341341
}
342342

343-
free_extent_map(em);
344343
out:
345344
write_unlock(&tree->lock);
345+
free_extent_map(em);
346346
return ret;
347347

348348
}

0 commit comments

Comments
 (0)