25aafc
From f05fe59ebbdfc07d738b393c18f951925dd3814d Mon Sep 17 00:00:00 2001
25aafc
Message-Id: <f05fe59ebbdfc07d738b393c18f951925dd3814d@dist-git>
25aafc
From: Jiang Kun <jiang.kun2@zte.com.cn>
25aafc
Date: Mon, 20 Jan 2020 08:51:25 +0100
25aafc
Subject: [PATCH] node_device_conf: Don't leak @physical_function in
25aafc
 virNodeDeviceGetPCISRIOVCaps
25aafc
MIME-Version: 1.0
25aafc
Content-Type: text/plain; charset=UTF-8
25aafc
Content-Transfer-Encoding: 8bit
25aafc
25aafc
The pci_dev->physical_function is rewritten in
25aafc
virPCIGetPhysicalFunction() to a newly allocated pointer.
25aafc
Therefore, we must free the old one to avoid memleak.
25aafc
25aafc
Signed-off-by: Jiang kun <jiang.kun2@zte.com.cn>
25aafc
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25aafc
(cherry picked from commit 38816336a5026623d0a49988c6681b1323c79f09)
25aafc
25aafc
https://bugzilla.redhat.com/show_bug.cgi?id=1792831
25aafc
https://bugzilla.redhat.com/show_bug.cgi?id=1793575
25aafc
https://bugzilla.redhat.com/show_bug.cgi?id=1793576
25aafc
25aafc
Signed-off-by: Ján Tomko <jtomko@redhat.com>
25aafc
Message-Id: <e0b84a11167f2d4f8e3fa1401959d907921c6df5.1579506302.git.jtomko@redhat.com>
25aafc
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
25aafc
---
25aafc
 src/conf/node_device_conf.c | 1 +
25aafc
 1 file changed, 1 insertion(+)
25aafc
25aafc
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
25aafc
index fd8f4e4a94..7f5afee41e 100644
25aafc
--- a/src/conf/node_device_conf.c
25aafc
+++ b/src/conf/node_device_conf.c
25aafc
@@ -2689,6 +2689,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
25aafc
     for (i = 0; i < pci_dev->num_virtual_functions; i++)
25aafc
        VIR_FREE(pci_dev->virtual_functions[i]);
25aafc
     VIR_FREE(pci_dev->virtual_functions);
25aafc
+    VIR_FREE(pci_dev->physical_function);
25aafc
     pci_dev->num_virtual_functions = 0;
25aafc
     pci_dev->max_virtual_functions = 0;
25aafc
     pci_dev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
25aafc
-- 
25aafc
2.25.0
25aafc