From: Myeonghun Pak <mhun512@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Ijae Kim <ae878000@gmail.com>
Subject: [PATCH 1/2] PCI: shpchp: Release MSI and MMIO resources on init failure
Date: Sun, 13 Sep 2026 21:24:33 -0400 [thread overview]
Message-ID: <20260914012434.47010-1-mhun512@gmail.com> (raw)
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@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
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;
}
next reply other threads:[~2026-09-14 1:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 1:24 Myeonghun Pak [this message]
2026-09-14 1:24 ` [PATCH 2/2] PCI: shpchp: Balance PCI device enable on teardown Myeonghun Pak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914012434.47010-1-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=ae878000@gmail.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®