On Tue, Jul 22, 2014 at 10:42:29PM -0600, Eric Blake wrote:
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)
While at it, fix switch statements to be a bit more vocal if we forget
some cases when adding new devices.
* src/conf/node_device_conf.c (virNodeDeviceDefFormat)
(virNodeDevCapsDefParseXML): Drop default case.
(virNodeDevCapsDefFree): Likewise, and clear pci_express under pci
case.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
I could be persuaded to split this into two patches.
That would be nice, now that you've mentioned it :)
src/conf/node_device_conf.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 910a371..4b34fec 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
[...]
@@ -1665,6 +1667,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr
caps)
VIR_FREE(data->pci_dev.iommuGroupDevices[i]);
}
VIR_FREE(data->pci_dev.iommuGroupDevices);
+ VIR_FREE(data->pci_dev.pci_express);
There should be data->pci_dev.pci_express->link_{sta,cap} free()'d too.
ACK with that changed.
Martin