Skip to content

Commit 6848ca3

Browse files
Yuanhe Shugregkh
authored andcommitted
Revert "PCI/MSI: Unmap MSI-X region on error"
[ Upstream commit f64e03d ] This reverts commit 1a8d4c6. Commit 1a8d4c6 ("PCI/MSI: Unmap MSI-X region on error") added an iounmap(dev->msix_base) on the error path of msix_capability_init() to release the MSI-X region when msix_setup_interrupts() fails. When msix_setup_interrupts() fails, the call chain is: msix_setup_interrupts() -> __msix_setup_interrupts() struct pci_dev *dev __free(free_msi_irqs) = __dev; ... return ret; // __free cleanup fires on error The __free(free_msi_irqs) cleanup calls pci_free_msi_irqs(), which already handles the unmap: void pci_free_msi_irqs(struct pci_dev *dev) { pci_msi_teardown_msi_irqs(dev); if (dev->msix_base) { iounmap(dev->msix_base); // already unmapped here dev->msix_base = NULL; // and set to NULL } } So dev->msix_base is unmapped and set to NULL before msix_setup_interrupts() returns to msix_capability_init(). The "goto out_unmap" introduced by commit 1a8d4c6 ("PCI/MSI: Unmap MSI-X region on error") then calls iounmap() a second time on a NULL pointer. This was reproduced on Intel Emerald Rapids (192 CPUs) while running tools/testing/selftests/kexec/test_kexec_jump.sh: WARNING: CPU#44 at iounmap+0x2a/0xe0 RIP: 0010:iounmap+0x2a/0xe0 RDI: 0000000000000000 Call Trace: msix_capability_init+0x317/0x3f0 __pci_enable_msix_range+0x21d/0x2c0 pci_alloc_irq_vectors_affinity+0xa9/0x130 nvme_setup_io_queues+0x2a8/0x420 [nvme] nvme_reset_work+0x151/0x340 [nvme] ... RDI=0 confirms iounmap() is called with NULL. Restore the original "goto out_disable" and leave the unmap to the existing __free(free_msi_irqs) cleanup. Fixes: 1a8d4c6 ("PCI/MSI: Unmap MSI-X region on error") Reported-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Yuanhe Shu <xiangzao@linux.alibaba.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://lore.kernel.org/all/20260610194406.GA380991@bhelgaas/ Link: https://patch.msgid.link/20260611025901.1105209-1-xiangzao@linux.alibaba.com Closes: https://lore.kernel.org/all/4fc6208d-513b-4f41-a13a-4a0829ab50ad@roeck-us.net/ Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2e605be commit 6848ca3

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/pci/msi/msi.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
737737

738738
ret = msix_setup_interrupts(dev, entries, nvec, affd);
739739
if (ret)
740-
goto out_unmap;
740+
goto out_disable;
741741

742742
/* Disable INTX */
743743
pci_intx_for_msi(dev, 0);
@@ -756,8 +756,6 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
756756
pcibios_free_irq(dev);
757757
return 0;
758758

759-
out_unmap:
760-
iounmap(dev->msix_base);
761759
out_disable:
762760
dev->msix_enabled = 0;
763761
pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE, 0);

0 commit comments

Comments
 (0)