[PATCH] xfs: fix potential NULL pointer dereference in zone GC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Under memory pressure, bio_alloc_bioset() may fail and return NULL,
which could lead to a NULL pointer dereference in the zone GC code.
Add proper error handling to prevent this scenario by checking the
return value and cleaning up resources appropriately.

Signed-off-by: Ye Chey <yechey@xxxxxxxxxxx>
---
 fs/xfs/xfs_zone_gc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
index d613a4094..ec87b5d6b 100644
--- a/fs/xfs/xfs_zone_gc.c
+++ b/fs/xfs/xfs_zone_gc.c
@@ -697,6 +697,11 @@ xfs_zone_gc_start_chunk(
 	}
 
 	bio = bio_alloc_bioset(bdev, 1, REQ_OP_READ, GFP_NOFS, &data->bio_set);
+	if (!bio) {
+		xfs_irele(ip);
+		xfs_open_zone_put(oz);
+		return false;
+	}
 
 	chunk = container_of(bio, struct xfs_gc_bio, bio);
 	chunk->ip = ip;
-- 
2.44.0





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux