mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] EDAC/x38: Fix mci_pdev reference leak in x38_init_one()
@ 2026-09-16  9:21 Wentao Liang
  2026-09-19  5:32 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16  9:21 UTC (permalink / raw)
  To: akpm
  Cc: bp, dougthompson, linux-edac, linux-kernel, mitake, tony.luck,
	Wentao Liang, stable

In x38_init_one(), a reference to the PCI device is taken with
pci_dev_get() and stored in the global mci_pdev even when x38_probe1()
fails.  On that path x38_registered keeps its initial value of 1, so
x38_exit() skips the pci_dev_put() and the reference is leaked.

Only take the reference after x38_probe1() succeeds.

Fixes: df8bc08c192f ("edac x38: new MC driver module")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/edac/x38_edac.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
index 292dda754c23..9c6542c4e3ee 100644
--- a/drivers/edac/x38_edac.c
+++ b/drivers/edac/x38_edac.c
@@ -423,10 +423,13 @@ 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)
+		return rc;
+
 	if (!mci_pdev)
 		mci_pdev = pci_dev_get(pdev);
 
-	return rc;
+	return 0;
 }
 
 static void x38_remove_one(struct pci_dev *pdev)
-- 
2.34.1


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

* Re: [PATCH] EDAC/x38: Fix mci_pdev reference leak in x38_init_one()
  2026-09-16  9:21 [PATCH] EDAC/x38: Fix mci_pdev reference leak in x38_init_one() Wentao Liang
@ 2026-09-19  5:32 ` Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2026-09-19  5:32 UTC (permalink / raw)
  To: Wentao Liang
  Cc: akpm, dougthompson, linux-edac, linux-kernel, mitake, tony.luck, stable

On Wed, Sep 16, 2026 at 09:21:21AM +0000, Wentao Liang wrote:
> In x38_init_one(), a reference to the PCI device is taken with
> pci_dev_get() and stored in the global mci_pdev even when x38_probe1()
> fails.  On that path x38_registered keeps its initial value of 1, so
> x38_exit() skips the pci_dev_put() and the reference is leaked.
> 
> Only take the reference after x38_probe1() succeeds.
> 
> Fixes: df8bc08c192f ("edac x38: new MC driver module")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/edac/x38_edac.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
> index 292dda754c23..9c6542c4e3ee 100644
> --- a/drivers/edac/x38_edac.c
> +++ b/drivers/edac/x38_edac.c
> @@ -423,10 +423,13 @@ 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)
> +		return rc;
> +
>  	if (!mci_pdev)
>  		mci_pdev = pci_dev_get(pdev);
>  
> -	return rc;
> +	return 0;
>  }
>  
>  static void x38_remove_one(struct pci_dev *pdev)
> -- 

We just orphaned this driver but it has been practically an orphan a long time
ago already.

No need to send fixes for it.

Thx.

-- 
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-19  5:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16  9:21 [PATCH] EDAC/x38: Fix mci_pdev reference leak in x38_init_one() Wentao Liang
2026-09-19  5:32 ` 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®