[libvirt] [PATCH] nodedev: fix pci express memory leak

Martin Kletzander mkletzan at redhat.com
Wed Jul 23 05:20:34 UTC 2014


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140723/b14de21e/attachment-0001.sig>


More information about the libvir-list mailing list