In haswell_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: 50d1bb93672f ("sb_edac: add support for Haswell based systems") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang --- 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 7b282dfd093f..5075c703e19e 100644 --- a/drivers/edac/sb_edac.c +++ b/drivers/edac/sb_edac.c @@ -2846,6 +2846,8 @@ static int haswell_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