Skip to content

Commit 690b7ca

Browse files
twilfredogregkh
authored andcommitted
xfs: fix memory leak on error in xfs_alloc_zone_info()
commit 592975da8c3ca87b043077e6eafa37665eae7936 upstream. 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: 080d01c ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b0bd7a8 commit 690b7ca

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/xfs/xfs_zone_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ xfs_alloc_zone_info(
11781178
return zi;
11791179

11801180
out_free_bitmaps:
1181-
while (--i > 0)
1181+
while (--i >= 0)
11821182
kvfree(zi->zi_used_bucket_bitmap[i]);
11831183
kfree(zi);
11841184
return NULL;

0 commit comments

Comments
 (0)