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

From: Borislav Petkov

Date: Tue Sep 15 2026 - 21:22:29 EST


This one looks old too.

On Mon, Sep 14, 2026 at 09:55:19PM -0400, Myeonghun Pak wrote:
> 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[] = {
>

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette