Leak introduced in commit
16ebf10f (v1.2.6), detected by valgrind:
==9816== 216 (96 direct, 120 indirect) bytes in 6 blocks are definitely lost in loss record 665 of 821
==9816== at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9816== by 0x50836FB: virAlloc (viralloc.c:144)
==9816== by 0x1DBDBE27: udevProcessPCI (node_device_udev.c:546)
==9816== by 0x1DBDD79D: udevGetDeviceDetails (node_device_udev.c:1293)
* src/util/virpci.h (virPCIEDeviceInfoFree): New prototype.
* src/util/virpci.c (virPCIEDeviceInfoFree): New function.
* src/conf/node_device_conf.c (virNodeDevCapsDefFree): Clear
pci_express under pci case.
(virNodeDevCapPCIDevParseXML): Avoid leak.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
* src/libvirt_private.syms (virpci.h): Export it.
Signed-off-by: Eric Blake <eblake@redhat.com>
ret = 0;
out:
- VIR_FREE(pci_express);
+ virPCIEDeviceInfoFree(pci_express);
ctxt->node = orignode;
return ret;
}
VIR_FREE(data->pci_dev.iommuGroupDevices[i]);
}
VIR_FREE(data->pci_dev.iommuGroupDevices);
+ virPCIEDeviceInfoFree(data->pci_dev.pci_express);
break;
case VIR_NODE_DEV_CAP_USB_DEV:
VIR_FREE(data->usb_dev.product_name);
virPCIDeviceSetUsedBy;
virPCIDeviceUnbind;
virPCIDeviceWaitForCleanup;
+virPCIEDeviceInfoFree;
virPCIGetNetName;
virPCIGetPhysicalFunction;
virPCIGetVirtualFunctionIndex;
out:
virPCIDeviceFree(pciDev);
- VIR_FREE(pci_express);
+ virPCIEDeviceInfoFree(pci_express);
return ret;
}
virPCIDeviceConfigClose(dev, fd);
return ret;
}
+
+
+void
+virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev)
+{
+ if (!dev)
+ return;
+
+ VIR_FREE(dev->link_cap);
+ VIR_FREE(dev->link_sta);
+ VIR_FREE(dev);
+}
unsigned int *cap_width,
unsigned int *sta_speed,
unsigned int *sta_width);
+
+void virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev);
+
#endif /* __VIR_PCI_H__ */