]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: fix a memory leak in xfs_buf_item_init()
authorHaoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Wed, 10 Dec 2025 09:06:01 +0000 (17:06 +0800)
committerCarlos Maiolino <cem@kernel.org>
Tue, 16 Dec 2025 07:50:11 +0000 (08:50 +0100)
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>
fs/xfs/xfs_buf_item.c

index 8d85b5eee444414ecd513d1d6ab5bf872a0fa275..f4c5be67826e2208e2c8e38a6281347a5cfa504a 100644 (file)
@@ -896,6 +896,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_cache, bip);
                        xfs_err(mp,
        "buffer item dirty bitmap (%u uints) too small to reflect %u bytes!",