[PATCH 2/2] PCI: shpchp: Balance PCI device enable on teardown

From: Myeonghun Pak

Date: Sun Sep 13 2026 - 21:26:59 EST


shpc_init() enables the PCI device, but neither initialization failure
after that point nor shpchp_release_ctlr() balances the enable.

Disable the device after releasing the controller resources. Route
reservation failures directly to the device cleanup, while failures
before pci_enable_device() succeeds continue to skip it.

The missing disable is 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
---
This patch depends on patch 1's error-unwind labels.
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 4492c7d..e00e4fb 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -572,6 +572,7 @@ void shpchp_release_ctlr(struct controller *ctrl)

iounmap(ctrl->creg);
release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
+ pci_disable_device(ctrl->pci_dev);
}

int shpchp_power_on_slot(struct slot *slot)
@@ -936,7 +937,7 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) {
ctrl_err(ctrl, "Cannot reserve MMIO region\n");
rc = -1;
- goto abort;
+ goto abort_disable_device;
}

ctrl->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size);
@@ -1045,6 +1046,8 @@ abort_disable_msi:
iounmap(ctrl->creg);
abort_release_region:
release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
+abort_disable_device:
+ pci_disable_device(pdev);
abort:
return rc;
}