Re: NULL pointer dereference in blk_queue_flag_set
From: Song Liu <song@kernel.org>
Date: 2022-02-02 06:57:53
Hi Leon, On Tue, Feb 1, 2022 at 2:15 PM jkhsjdhjs [off-list ref] wrote:
Dear Song Liu, my kernel (5.17-rc2) experiences a NULL pointer dereference when activating an LDM (Windows Logical Disk Manager) on Arch Linux using ldmtool [1]. I have attached the relevant excerpt of dmesg. This bug causes my LDM RAID to fail activating (see ldmtool-status.txt and lsblk.txt). Since this worked fine with 5.16 I bisected the kernel and found, that commit f51d46d0e7cb5b8494aa534d276a9d8915a2443d [2] introduced the issue. I'm not sure what else to add, if there's more information I can provide, please tell me. Otherwise I'll happily assist in fixing this issue - if there's something I can do.
Thanks for the report! And sorry for the bug. For the next step, could you please test whether the following change fixes the issue? Best, Song
diff --git i/drivers/md/md.c w/drivers/md/md.c
index 854cbf4234aa..18e987c644c6 100644
--- i/drivers/md/md.c
+++ w/drivers/md/md.c@@ -5868,10 +5868,6 @@ int md_run(struct mddev *mddev) nowait = nowait && blk_queue_nowait(bdev_get_queue(rdev->bdev)); } - /* Set the NOWAIT flags if all underlying devices support it */ - if (nowait) - blk_queue_flag_set(QUEUE_FLAG_NOWAIT, mddev->queue); - if (!bioset_initialized(&mddev->bio_set)) { err = bioset_init(&mddev->bio_set, BIO_POOL_SIZE, 0,
BIOSET_NEED_BVECS);
if (err)@@ -6009,6 +6005,10 @@ int md_run(struct mddev *mddev) else blk_queue_flag_clear(QUEUE_FLAG_NONROT, mddev->queue); blk_queue_flag_set(QUEUE_FLAG_IO_STAT, mddev->queue); + + /* Set the NOWAIT flags if all underlying devices support it */ + if (nowait) + blk_queue_flag_set(QUEUE_FLAG_NOWAIT, mddev->queue); } if (pers->sync_request) { if (mddev->kobj.sd &&