xfs: fix memory leak on error in xfs_alloc_zone_info()
Subsystems (2)
PATCH v2 1/1 xfs: fix memory leak on error in xfs_alloc_zone_info()
From: Wilfred Mallawa <[email protected]>
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.
--- fs/xfs/xfs_zone_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_zone_alloc.c +1 -1
@@ -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 ;
Signature · 1 line
2.53.0
Quoted 9 lines · Wilfred Mallawa
From: Wilfred Mallawa <[email protected]>
Currently, the 0th index of the
zi_used_bucket_bitmaparray is not freed on error due to the pre-decrement then evaluate semantic of the while loop used inxfs_alloc_zone_info(). Fix it by allowing for the i == 0 case to be covered.Fixes 080d01c41d44 ("xfs: implement zoned garbage collection")
(autobackport plz, I need all the help I can get)
Quoted 12 lines
Reviewed-by Damien Le Moal <[email protected]>Reviewed-by Carlos Maiolino <[email protected]>Signed-off-by Wilfred Mallawa <[email protected]>--- fs/xfs/xfs_zone_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_zone_alloc.c +0
-0
fs/xfs/xfs_zone_alloc.c xfs_alloc_zone_info( · line 1220
Quoted 5 lines
fs/xfs/xfs_zone_alloc.c +1
-1@@ -1217,7 +1217,7 @@ xfs_alloc_zone_info(return zi; out_free_bitmaps: -while (--i >0 ) +while (--i >=0 )
With the git trailer amended,
--D
Quoted 7 lines
fs/xfs/xfs_zone_alloc.c +0
-0kvfree (zi->zi_used_bucket_bitmap[i]);kfree (zi);return NULL ;Signature · 1 line
2.53.0
Looks good:
Quoted 21 lines · Wilfred Mallawa
From: Wilfred Mallawa <[email protected]>
Currently, the 0th index of the
zi_used_bucket_bitmaparray is not freed on error due to the pre-decrement then evaluate semantic of the while loop used inxfs_alloc_zone_info(). Fix it by allowing for the i == 0 case to be covered.Fixes 080d01c41d44 ("xfs: implement zoned garbage collection")Reviewed-by Damien Le Moal <[email protected]>Reviewed-by Carlos Maiolino <[email protected]>Signed-off-by Wilfred Mallawa <[email protected]>--- fs/xfs/xfs_zone_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_zone_alloc.c +0
-0
fs/xfs/xfs_zone_alloc.c xfs_alloc_zone_info( · line 1223
Quoted 8 lines
fs/xfs/xfs_zone_alloc.c +1
-1@@ -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 ;
Thanks!
Quoted 6 lines · Wilfred Mallawa
Currently, the 0th index of the
zi_used_bucket_bitmaparray is not freed on error due to the pre-decrement then evaluate semantic of the while loop used inxfs_alloc_zone_info(). Fix it by allowing for the i == 0 case to be covered.
Applied to for-next, thanks!
[1/1] xfs: fix memory leak on error in xfs_alloc_zone_info()
commit: 592975da8c3ca87b043077e6eafa37665eae7936
Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>