[libvirt] [PATCH] fix memleak in virNodeDeviceGetPCISRIOVCaps

Yi Wang posted 1 patch 4 years, 7 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1568275539-15079-1-git-send-email-wang.yi59@zte.com.cn
src/conf/node_device_conf.c | 1 +
1 file changed, 1 insertion(+)
[libvirt] [PATCH] fix memleak in virNodeDeviceGetPCISRIOVCaps
Posted by Yi Wang 4 years, 7 months ago
From: Jiang Kun <jiang.kun2@zte.com.cn>

it always alloc new memory when get dumpxml of pf device,but never free it.
Now free the old first,then alloc new memory.

Signed-off-by: Jiang kun <jiang.kun2@zte.com.cn>
---
 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 e51371d..618ce8e 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2509,6 +2509,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;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix memleak in virNodeDeviceGetPCISRIOVCaps
Posted by Michal Privoznik 4 years, 7 months ago
On 9/12/19 10:05 AM, Yi Wang wrote:
> From: Jiang Kun <jiang.kun2@zte.com.cn>
> 
> it always alloc new memory when get dumpxml of pf device,but never free it.
> Now free the old first,then alloc new memory.
> 
> Signed-off-by: Jiang kun <jiang.kun2@zte.com.cn>
> ---
>   src/conf/node_device_conf.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and pushed.
Congratulations Jiang on your first libvirt contribution.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list