[PATCH] EDAC/sb_edac: Fix pci_vtd reference leak in broadwell_mci_bind_devs()

Wentao Liang posted 1 patch 1 week, 1 day ago
drivers/edac/sb_edac.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] EDAC/sb_edac: Fix pci_vtd reference leak in broadwell_mci_bind_devs()
Posted by Wentao Liang 1 week, 1 day ago
In broadwell_mci_bind_devs(), a reference to the VT-d device is taken
with pci_get_device() and stored in pvt->info.pci_vtd.  If one of the
required devices is missing, the function returns -ENODEV without
putting that reference, and the caller frees the mem_ctl_info along
with its private data, leaking the reference.

Put the device reference before returning on the error path.

Fixes: 1f39581a9a7a ("sb_edac: Add support for Broadwell-DE processor")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/edac/sb_edac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 5075c703e19e..7ec29e50f5d7 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -2929,6 +2929,8 @@ static int broadwell_mci_bind_devs(struct mem_ctl_info *mci,
 	return 0;
 
 enodev:
+	pci_dev_put(pvt->info.pci_vtd);
+	pvt->info.pci_vtd = NULL;
 	sbridge_printk(KERN_ERR, "Some needed devices are missing\n");
 	return -ENODEV;
 }
-- 
2.34.1