[PATCH 1/2] PCI: shpchp: Release MSI and MMIO resources on init failure

From: Myeonghun Pak

Date: Sun Sep 13 2026 - 21:24:53 EST


If request_irq() fails after enabling MSI, shpc_init() unmaps the
registers but leaves MSI enabled and the MMIO region reserved.

Disable MSI before unmapping and release the reserved region on the
failure path. Reuse the region cleanup for an ioremap() failure.
pci_disable_msi() also handles the INTx fallback where MSI was not enabled.

These omissions are already present in the initial Git import.

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

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
Assisted-by: OpenAI:GPT-5.6
---
Validated with an ARM64 W=1 object build and strict checkpatch.
No hardware runtime, IRQ-failure injection or hotplug testing was done.

diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 183bf43..4492c7d 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -943,9 +943,8 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
if (!ctrl->creg) {
ctrl_err(ctrl, "Cannot remap MMIO region %lx @ %lx\n",
ctrl->mmio_size, ctrl->mmio_base);
- release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
rc = -1;
- goto abort;
+ goto abort_release_region;
}
ctrl_dbg(ctrl, "ctrl->creg %p\n", ctrl->creg);

@@ -1008,7 +1007,7 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
if (rc) {
ctrl_err(ctrl, "Can't get irq %d for the hotplug controller\n",
ctrl->pci_dev->irq);
- goto abort_iounmap;
+ goto abort_disable_msi;
}
}
ctrl_dbg(ctrl, "HPC at %s irq=%x\n", pci_name(pdev), pdev->irq);
@@ -1041,8 +1040,11 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
return 0;

/* We end up here for the many possible ways to fail this API. */
-abort_iounmap:
+abort_disable_msi:
+ pci_disable_msi(pdev);
iounmap(ctrl->creg);
+abort_release_region:
+ release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
abort:
return rc;
}