Skip to contentSkip to conversation

nvme-pci: disable controller on admin queue IRQ setup failure

PATCH Applied Myeonghun Pak 3 participants 3 messages Jul 15 – Jul 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-pci: disable controller on admin queue IRQ setup failure

nvme_pci_configure_admin_queue() enables the controller and then requests the admin queue interrupt. If queue_request_irq() fails it returns without disabling the controller, and no caller compensates: nvme_pci_enable() only frees the IRQ vectors and calls pci_disable_device(), after which nvme_dev_disable() treats the controller as dead and skips nvme_disable_ctrl(). The controller is left enabled (CC.EN set) on this error path.

Disable it in the failure path, while the PCI device is still enabled so the CC.EN clear handshake completes.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes b60503ba432b ("NVMe: New driver")
---
 drivers/nvme/host/pci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
index 2f0c05719316..07aa9af9bc89 100644
@@ -2221,6 +2221,7 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev)
 	result = queue_request_irq(nvmeq);
 	if (result) {
 		dev->online_queues--;
+		nvme_disable_ctrl(&dev->ctrl, false);
 		return result;
 	}
 
Signature · 1 line
2.47.1
maintainer Applied
#2 lore raw
In reply to Myeonghun Pak
Quoted 9 lines · Myeonghun Pak

nvme_pci_configure_admin_queue() enables the controller and then requests the admin queue interrupt. If queue_request_irq() fails it returns without disabling the controller, and no caller compensates: nvme_pci_enable() only frees the IRQ vectors and calls pci_disable_device(), after which nvme_dev_disable() treats the controller as dead and skips nvme_disable_ctrl(). The controller is left enabled (CC.EN set) on this error path.

Disable it in the failure path, while the PCI device is still enabled so the CC.EN clear handshake completes.

Thanks, applied to nvme-7.3.