Skip to content

Commit fc40459

Browse files
Haoxiang Licmaiolino
authored andcommitted
xfs: fix a memory leak in xfs_buf_item_init()
xfs_buf_item_get_format() may allocate memory for bip->bli_formats, free the memory in the error path. Fixes: c3d5f0c ("xfs: complain if anyone tries to create a too-large buffer log item") Cc: stable@vger.kernel.org Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent f067250 commit fc40459

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/xfs/xfs_buf_item.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ xfs_buf_item_init(
896896
map_size = DIV_ROUND_UP(chunks, NBWORD);
897897

898898
if (map_size > XFS_BLF_DATAMAP_SIZE) {
899+
xfs_buf_item_free_format(bip);
899900
kmem_cache_free(xfs_buf_item_cache, bip);
900901
xfs_err(mp,
901902
"buffer item dirty bitmap (%u uints) too small to reflect %u bytes!",

0 commit comments

Comments
 (0)