render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From f05fe59ebbdfc07d738b393c18f951925dd3814d Mon Sep 17 00:00:00 2001
Message-Id: <f05fe59ebbdfc07d738b393c18f951925dd3814d@dist-git>
From: Jiang Kun <jiang.kun2@zte.com.cn>
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 <jiang.kun2@zte.com.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(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 <jtomko@redhat.com>
Message-Id: <e0b84a11167f2d4f8e3fa1401959d907921c6df5.1579506302.git.jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
---
 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