Skip to content

Commit 751a0cc

Browse files
igorkonopkoChristoph Hellwig
authored andcommitted
nvme-pci: fix surprise removal
When a PCIe NVMe device is not present, nvme_dev_remove_admin() calls blk_cleanup_queue() on the admin queue, which frees the hctx for that queue. Moments later, on the same path nvme_kill_queues() calls blk_mq_unquiesce_queue() on admin queue and tries to access hctx of it, which leads to following OOPS: Oops: 0000 [#1] SMP PTI RIP: 0010:sbitmap_any_bit_set+0xb/0x40 Call Trace: blk_mq_run_hw_queue+0xd5/0x150 blk_mq_run_hw_queues+0x3a/0x50 nvme_kill_queues+0x26/0x50 nvme_remove_namespaces+0xb2/0xc0 nvme_remove+0x60/0x140 pci_device_remove+0x3b/0xb0 Fixes: cb4bfda ("nvme-pci: fix hot removal during error handling") Signed-off-by: Igor Konopko <[email protected]> Reviewed-by: Keith Busch <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent dfa7442 commit 751a0cc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3607,7 +3607,7 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl)
36073607
down_read(&ctrl->namespaces_rwsem);
36083608

36093609
/* Forcibly unquiesce queues to avoid blocking dispatch */
3610-
if (ctrl->admin_q)
3610+
if (ctrl->admin_q && !blk_queue_dying(ctrl->admin_q))
36113611
blk_mq_unquiesce_queue(ctrl->admin_q);
36123612

36133613
list_for_each_entry(ns, &ctrl->namespaces, list)

0 commit comments

Comments
 (0)