]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: fix memory leak on error in xfs_alloc_zone_info()
authorWilfred Mallawa <wilfred.mallawa@wdc.com>
Tue, 14 Apr 2026 23:45:14 +0000 (09:45 +1000)
committerCarlos Maiolino <cem@kernel.org>
Mon, 27 Apr 2026 08:36:36 +0000 (10:36 +0200)
Currently, the 0th index of the zi_used_bucket_bitmap array is not freed
on error due to the pre-decrement then evaluate semantic of the while
loop used in xfs_alloc_zone_info(). Fix it by allowing for the i == 0
case to be covered.

Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection")
Cc: stable@vger.kernel.org # v6.15
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_zone_alloc.c

index a851b98143c0b4149bead6e744180aa40a13047f..c64f9ab743a60ae7f281fefd87f031240101ba57 100644 (file)
@@ -1217,7 +1217,7 @@ xfs_alloc_zone_info(
        return zi;
 
 out_free_bitmaps:
-       while (--i > 0)
+       while (--i >= 0)
                kvfree(zi->zi_used_bucket_bitmap[i]);
        kfree(zi);
        return NULL;