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