public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pktcdvd: fix missing bio_alloc_clone NULL check in pkt_make_request_read
@ 2025-05-21 12:30 Ye Chey
  2025-05-21 16:13 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Ye Chey @ 2025-05-21 12:30 UTC (permalink / raw)
  To: linux-block, axboe; +Cc: Ye Chey

The bio_alloc_clone() call in pkt_make_request_read() lacks NULL check,
which could lead to NULL pointer dereference. Add NULL check and handle
allocation failure by calling bio_io_error().

Signed-off-by: Ye Chey <yechey@ai-sast.com>
---
 drivers/block/pktcdvd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 65b96c083..68d1f43a7 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2323,6 +2323,10 @@ static void pkt_make_request_read(struct pktcdvd_device *pd, struct bio *bio)
 {
 	struct bio *cloned_bio = bio_alloc_clone(file_bdev(pd->bdev_file), bio,
 		GFP_NOIO, &pkt_bio_set);
+	if (!cloned_bio) {
+		bio_io_error(bio);
+		return;
+	}
 	struct packet_stacked_data *psd = mempool_alloc(&psd_pool, GFP_NOIO);
 
 	psd->pd = pd;
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-21 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 12:30 [PATCH] pktcdvd: fix missing bio_alloc_clone NULL check in pkt_make_request_read Ye Chey
2025-05-21 16:13 ` Christoph Hellwig
2025-05-21 17:47   ` yechey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox