Re: [PATCH] md: fix potential NULL pointer dereference in md_super_write

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

 



Hi,

在 2025/05/23 17:35, Ye Chey 写道:
The bio_alloc_bioset() call in md_super_write() could fail under memory
pressure and return NULL. Add a check to handle this case gracefully by
returning early, preventing a potential NULL pointer dereference.

NAK, if you read the comments of bio_alloc_bioset(), you'll know there
are cases bio_alloc_bioset() will never return NULL.

Thanks,
Kuai


Signed-off-by: Ye Chey <yechey@xxxxxxxxxxx>
---
  drivers/md/md.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9daa78c5f..a0e2d90d4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1002,6 +1002,8 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev,
  			      REQ_OP_WRITE | REQ_SYNC | REQ_IDLE | REQ_META
  				  | REQ_PREFLUSH | REQ_FUA,
  			      GFP_NOIO, &mddev->sync_set);
+	if (!bio)
+		return;
atomic_inc(&rdev->nr_pending);





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux