From: Ye Chey <yechey@ai-sast.com>
To: philipp.reisner@linbit.com, lars.ellenberg@linbit.com,
christoph.boehmwalder@linbit.com, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Ye Chey <yechey@ai-sast.com>
Subject: [PATCH] drbd: fix potential NULL pointer dereference in drbd_md_sync_page_io
Date: Fri, 23 May 2025 16:55:29 +0800 [thread overview]
Message-ID: <20250523085529.85368-1-yechey@ai-sast.com> (raw)
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
next reply other threads:[~2025-05-23 8:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 8:55 Ye Chey [this message]
2025-05-23 10:05 ` [PATCH] drbd: fix potential NULL pointer dereference in drbd_md_sync_page_io Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250523085529.85368-1-yechey@ai-sast.com \
--to=yechey@ai-sast.com \
--cc=axboe@kernel.dk \
--cc=christoph.boehmwalder@linbit.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=philipp.reisner@linbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox