* [PATCH] drbd: fix potential NULL pointer dereference in drbd_md_sync_page_io
@ 2025-05-23 8:55 Ye Chey
2025-05-23 10:05 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Ye Chey @ 2025-05-23 8:55 UTC (permalink / raw)
To: philipp.reisner, lars.ellenberg, christoph.boehmwalder, axboe
Cc: linux-block, linux-kernel, Ye Chey
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@ai-sast.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drbd: fix potential NULL pointer dereference in drbd_md_sync_page_io
2025-05-23 8:55 [PATCH] drbd: fix potential NULL pointer dereference in drbd_md_sync_page_io Ye Chey
@ 2025-05-23 10:05 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2025-05-23 10:05 UTC (permalink / raw)
To: Ye Chey
Cc: philipp.reisner, lars.ellenberg, christoph.boehmwalder, axboe,
linux-block, linux-kernel
On Fri, May 23, 2025 at 04:55:29PM +0800, Ye Chey wrote:
> Under memory pressure, bio_alloc_bioset() may fail and return NULL.
No, not with the GFP_ flag passed here.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-23 10:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 8:55 [PATCH] drbd: fix potential NULL pointer dereference in drbd_md_sync_page_io Ye Chey
2025-05-23 10:05 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox