[PATCH] drbd: fix potential NULL pointer dereference in drbd_md_sync_page_io

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

 



Under memory pressure, bio_alloc_bioset() may fail and return NULL. Add a
check to handle this case gracefully by returning -ENOMEM instead of
dereferencing a NULL pointer.

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

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index 742b2908f..68b925b49 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -141,6 +141,10 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
 
 	bio = bio_alloc_bioset(bdev->md_bdev, 1, op | op_flags, GFP_NOIO,
 			       &drbd_md_io_bio_set);
+	if (!bio) {
+		err = -ENOMEM;
+		goto out;
+	}
 	bio->bi_iter.bi_sector = sector;
 	err = -EIO;
 	if (bio_add_page(bio, device->md_io.page, size, 0) != size)
-- 
2.44.0





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux