EDAC/x38: Fix mci_pdev reference leak in x38_init_one()
Subsystems (3)
PATCH 1/1 EDAC/x38: Fix mci_pdev reference leak in x38_init_one()
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.
--- drivers/edac/x38_edac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/edac/x38_edac.c +4 -1
@@ -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)
Signature · 1 line
2.34.1
Borislav Petkov
maintainerQuoted 24 lines · Wentao Liang
In
x38_init_one(), a reference to the PCI device is taken withpci_dev_get()and stored in the globalmci_pdeveven whenx38_probe1()fails. On that pathx38_registeredkeeps its initial value of 1, sox38_exit()skips thepci_dev_put()and the reference is leaked.Only take the reference after
x38_probe1()succeeds.Fixes df8bc08c192f ("edac x38: new MC driver module")Signed-off-by Wentao Liang <[email protected]>--- drivers/edac/x38_edac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/edac/x38_edac.c +1
-0@@ -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)
drivers/edac/x38_edac.c static int x38_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 435
Quoted 10 lines
drivers/edac/x38_edac.c +3
-1+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.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette