mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] EDAC/i82975x: Balance PCI ownership on probe and module exit
@ 2026-09-15  1:35 Myeonghun Pak
  2026-09-16  1:38 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-09-15  1:35 UTC (permalink / raw)
  To: Arvind R.; +Cc: Borislav Petkov, Tony Luck, linux-edac, linux-kernel, stable

i82975x_init_one() leaves its PCI enable reference behind on failure
and removal. Also, the fallback probe is never removed at module exit:
i82975x_registered is initialized to one and never changed.

Balance PCI enablement and track successful fallback initialization so
module exit removes controllers that are not bound to the PCI driver.
Only remember a normally probed device after successful initialization,
and release the saved device reference on both normal and fallback exit.

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

Fixes: 420390f06a5a ("drivers/edac: new i82975x driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/edac/i82975x_edac.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
--- a/drivers/edac/i82975x_edac.c
+++ b/drivers/edac/i82975x_edac.c
@@ -233,7 +233,7 @@ static struct pci_dev *mci_pdev;
 					 * already registered driver
 					 */
 
-static int i82975x_registered = 1;
+static bool i82975x_fallback;
 
 static void i82975x_get_error_info(struct mem_ctl_info *mci,
 		struct i82975x_error_info *info)
@@ -597,6 +597,10 @@ static int i82975x_init_one(struct pci_dev *pdev,
 		return -EIO;
 
 	rc = i82975x_probe1(pdev, ent->driver_data);
+	if (rc) {
+		pci_disable_device(pdev);
+		return rc;
+	}
 
 	if (mci_pdev == NULL)
 		mci_pdev = pci_dev_get(pdev);
@@ -620,6 +624,7 @@ static void i82975x_remove_one(struct pci_dev *pdev)
 		iounmap( pvt->mch_window );
 
 	edac_mc_free(mci);
+	pci_disable_device(pdev);
 }
 
 static const struct pci_device_id i82975x_pci_tbl[] = {
@@ -670,6 +675,7 @@ static int __init i82975x_init(void)
 			pci_rc = -ENODEV;
 			goto fail1;
 		}
+		i82975x_fallback = true;
 	}
 
 	return 0;
@@ -688,10 +694,9 @@ static void __exit i82975x_exit(void)
 
 	pci_unregister_driver(&i82975x_driver);
 
-	if (!i82975x_registered) {
+	if (i82975x_fallback)
 		i82975x_remove_one(mci_pdev);
-		pci_dev_put(mci_pdev);
-	}
+	pci_dev_put(mci_pdev);
 }
 
 module_init(i82975x_init);
-- 
2.51.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] EDAC/i82975x: Balance PCI ownership on probe and module exit
  2026-09-15  1:35 [PATCH] EDAC/i82975x: Balance PCI ownership on probe and module exit Myeonghun Pak
@ 2026-09-16  1:38 ` Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2026-09-16  1:38 UTC (permalink / raw)
  To: Arvind R.; +Cc: Myeonghun Pak, Tony Luck, linux-edac, linux-kernel

On Mon, Sep 14, 2026 at 09:35:37PM -0400, Myeonghun Pak wrote:
> i82975x_init_one() leaves its PCI enable reference behind on failure
> and removal. Also, the fallback probe is never removed at module exit:
> i82975x_registered is initialized to one and never changed.
> 
> Balance PCI enablement and track successful fallback initialization so
> module exit removes controllers that are not bound to the PCI driver.
> Only remember a normally probed device after successful initialization,
> and release the saved device reference on both normal and fallback exit.
> 
> This issue was identified during our ongoing static-analysis research
> while reviewing kernel code.
> 
> Fixes: 420390f06a5a ("drivers/edac: new i82975x driver")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  drivers/edac/i82975x_edac.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)

Arvind R., lemme know if you'd like to have an entry in CREDITS.

And if so, you can suggest one.

Thx.

From: "Borislav Petkov (AMD)" <bp@alien8.de>
Date: Tue, 15 Sep 2026 18:27:46 -0700
Subject: [PATCH] MAINTAINERS: Orphan drivers/edac/i82975x_edac.c

The driver has only been "carried forward" without any recent
maintainership interest or testing. Orphan it.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index c2414447892c..d0c02c08b670 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9472,9 +9472,8 @@ S:	Maintained
 F:	drivers/edac/i7core_edac.c
 
 EDAC-I82975X
-M:	"Arvind R." <arvino55@gmail.com>
 L:	linux-edac@vger.kernel.org
-S:	Maintained
+S:	Orphan
 F:	drivers/edac/i82975x_edac.c
 
 EDAC-IE31200
-- 
2.53.0

-- 
Regards/Gruss,
    Boris.

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-16  1:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  1:35 [PATCH] EDAC/i82975x: Balance PCI ownership on probe and module exit Myeonghun Pak
2026-09-16  1:38 ` Borislav Petkov

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®