]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xfs: fix a memory leak in xfs_buf_item_init()
authorHaoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Wed, 31 Dec 2025 03:15:44 +0000 (22:15 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:10:07 +0000 (13:10 +0100)
[ 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 <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>
[ Adjust context ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/xfs_buf_item.c

index b1ab100c09e1447a4a538d4d24dba9c50a7a4817..9f8225ed234eb2d7c3d614525e491f03c83347d8 100644 (file)
@@ -825,6 +825,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!",