[PATCH] md: fix NULL point access
From: Chaohai Chen
Date: Fri Dec 27 2024 - 21:16:18 EST
bio_alloc_bioset may return NULL, we need to judge it before
assign value to members of "new".
Signed-off-by: Chaohai Chen <wdhh66@xxxxxxx>
---
drivers/md/md.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index aebe12b0ee27..a23419ad3dd8 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -585,6 +585,8 @@ bool md_flush_request(struct mddev *mddev, struct bio *bio)
new = bio_alloc_bioset(rdev->bdev, 0,
REQ_OP_WRITE | REQ_PREFLUSH, GFP_NOIO,
&mddev->bio_set);
+ if (!new)
+ continue;
new->bi_private = bio;
new->bi_end_io = md_end_flush;
bio_inc_remaining(bio);
--
2.34.1