]> 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:19:04 +0000 (22:19 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:12:02 +0000 (13:12 +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 a3d5ecccfc2ccf72f20e50eea674f59e60b8e6c3..deb69740d492f88eb92c47863acd264dba0cca82 100644 (file)
@@ -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!",