From: Haoxiang Li Date: Wed, 31 Dec 2025 03:19:04 +0000 (-0500) Subject: xfs: fix a memory leak in xfs_buf_item_init() X-Git-Tag: v5.10.248~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d90a061c0910ece3f9dc3e8b4f03c4d2e0cc4db;p=thirdparty%2Fkernel%2Fstable.git xfs: fix a memory leak in xfs_buf_item_init() [ Upstream commit fc40459de82543b565ebc839dca8f7987f16f62e ] xfs_buf_item_get_format() may allocate memory for bip->bli_formats, free the memory in the error path. Fixes: c3d5f0c2fb85 ("xfs: complain if anyone tries to create a too-large buffer log item") Cc: stable@vger.kernel.org Signed-off-by: Haoxiang Li Reviewed-by: Christoph Hellwig Reviewed-by: Carlos Maiolino Signed-off-by: Carlos Maiolino [ Adjust context ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index a3d5ecccfc2cc..deb69740d492f 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -744,6 +744,7 @@ xfs_buf_item_init( map_size = DIV_ROUND_UP(chunks, NBWORD); if (map_size > XFS_BLF_DATAMAP_SIZE) { + xfs_buf_item_free_format(bip); kmem_cache_free(xfs_buf_item_zone, bip); xfs_err(mp, "buffer item dirty bitmap (%u uints) too small to reflect %u bytes!",