diff mbox series

[2/2] PCI: hv: Add missing kfree(hbus) in hv_pci_probe()'s error handling path

Message ID 20220517142234.11048-3-tim.gardner@canonical.com
State New
Headers show
Series [1/2] PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer | expand

Commit Message

Tim Gardner May 17, 2022, 2:22 p.m. UTC
From: Dexuan Cui <decui@microsoft.com>

BugLink: https://bugs.launchpad.net/bugs/1973758

Now that we use kzalloc() to allocate the hbus buffer, we must call
kfree() in the error path as well to prevent memory leakage.

Fixes: 877b911a5ba0 ("PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
(cherry picked from commit 42c3d41832ef4fcf60aaa6f748de01ad99572adf)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/pci/controller/pci-hyperv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index ea5aded65ec1..5714c313f548 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -3562,7 +3562,7 @@  static int hv_pci_probe(struct hv_device *hdev,
 free_dom:
 	hv_put_dom_num(hbus->bridge->domain_nr);
 free_bus:
-	free_page((unsigned long)hbus);
+	kfree(hbus);
 	return ret;
 }