[PATCH 3/3] EDAC/x38: Balance PCI device enablement

From: Myeonghun Pak

Date: Mon Sep 14 2026 - 22:01:21 EST


x38_init_one() leaves the PCI enable reference held when probing fails
and when the controller is removed. Disable the device on probe failure
and after removing the EDAC controller. Keep explicit cleanup because
module initialization can call x38_init_one() outside PCI driver binding.

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

Fixes: df8bc08c192f ("edac x38: new MC driver module")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
---
drivers/edac/x38_edac.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
--- a/drivers/edac/x38_edac.c
+++ b/drivers/edac/x38_edac.c
@@ -423,6 +423,8 @@ static int x38_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return -EIO;

rc = x38_probe1(pdev, ent->driver_data);
+ if (rc)
+ pci_disable_device(pdev);
if (!mci_pdev)
mci_pdev = pci_dev_get(pdev);

@@ -439,9 +441,11 @@ static void x38_remove_one(struct pci_dev *pdev)
if (!mci)
return;

iounmap(mci->pvt_info);

edac_mc_free(mci);
+
+ pci_disable_device(pdev);
}

static const struct pci_device_id x38_pci_tbl[] = {