[PATCH] block: check the existence of tags[hctx_idx] in blk_mq_clear_rq_mapping()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to commit 4412efecf7fd ("Revert "blk-mq: remove code for
dealing with remapping queue""), for some devices queue hctx may not
being mapped, and tagset->tags[hctx_idx] will be released and be NULL.

If an IO scheduler is used on these devices, blk_mq_clear_rq_mapping()
will be called for all hctxs in blk_mq_sched_free_requests() during
scheduler switch, and these will be oops. So checking the existence of
tags[hctx_idx] before going on in blk_mq_clear_rq_mapping().

Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
---
 block/blk-mq.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 65d3a63aecc6..c3d701f44e49 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2297,6 +2297,10 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tag_set *set,
 	struct page *page;
 	unsigned long flags;
 
+	/* If the hctx is unmapped, drv_tags may be NULL */
+	if (!drv_tags)
+		return;
+
 	list_for_each_entry(page, &tags->page_list, lru) {
 		unsigned long start = (unsigned long)page_address(page);
 		unsigned long end = start + order_to_size(page->private);
-- 
2.29.2




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux