[libvirt] [PATCH 4/4] Resolve valgrind errors for nodedev cap parsing

Laine Stump laine at laine.org
Fri Jun 28 19:46:11 UTC 2013


On 06/28/2013 03:25 PM, John Ferlan wrote:
> There were two errors, one as a direct result of commit id '8807b285'
> and the other from cut-n-paste
>
> TEST: nodedevxml2xmltest
>       ..............                           14  OK
> ==25735== 3 bytes in 1 blocks are definitely lost in loss record 1 of 24
> ==25735==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
> ==25735==    by 0x344D2AF275: xmlStrndup (in /usr/lib64/libxml2.so.2.9.1)
> ==25735==    by 0x4D0C767: virNodeDeviceDefParseNode (node_device_conf.c:997)
> ==25735==    by 0x4D0D3D2: virNodeDeviceDefParse (node_device_conf.c:1337)
> ==25735==    by 0x401CA4: testCompareXMLToXMLHelper (nodedevxml2xmltest.c:28)
> ==25735==    by 0x402B2F: virtTestRun (testutils.c:158)
> ==25735==    by 0x401B27: mymain (nodedevxml2xmltest.c:81)
> ==25735==    by 0x40316A: virtTestMain (testutils.c:722)
> ==25735==    by 0x37C1021A04: (below main) (libc-start.c:225)
> ==25735==
> ==25735== 16 bytes in 1 blocks are definitely lost in loss record 10 of 24
> ==25735==    at 0x4A08A6E: realloc (vg_replace_malloc.c:662)
> ==25735==    by 0x4C7385E: virReallocN (viralloc.c:184)
> ==25735==    by 0x4C73906: virExpandN (viralloc.c:214)
> ==25735==    by 0x4C73B4A: virInsertElementsN (viralloc.c:324)
> ==25735==    by 0x4D0C84C: virNodeDeviceDefParseNode (node_device_conf.c:1026)
> ==25735==    by 0x4D0D3D2: virNodeDeviceDefParse (node_device_conf.c:1337)
> ==25735==    by 0x401CA4: testCompareXMLToXMLHelper (nodedevxml2xmltest.c:28)
> ==25735==    by 0x402B2F: virtTestRun (testutils.c:158)
> ==25735==    by 0x401B27: mymain (nodedevxml2xmltest.c:81)
> ==25735==    by 0x40316A: virtTestMain (testutils.c:722)
> ==25735==    by 0x37C1021A04: (below main) (libc-start.c:225)
> ==25735==
> PASS: nodedevxml2xmltest
>
> The first error was resolved by adding a missing VIR_FREE(numberStr); in
> the new function virNodeDevCapPciDevIommuGroupParseXML().
>
> The second error was a bit more opaque as the error was a result of copying
> the free methodolgy of the existing code in virNodeDevCapsDefFree(). The code
> would free each of the entries in the array, but not the memory for the
> array itself.  Added the necessary VIR_FREE(data->pci_dev.iommuGroupDevices)
> and while at it added the missing VIR_FREE(data->pci_dev.virtual_functions)
> although there wasn't a test that tripped across it 

Yeah, I noticed when I added the iommuGroupDevices that neither
virtual_functions nor physical_function are included the in nodedev
parser, nor are they tested in the nodedevxml2xml test. I have that on
my mental list of things to put in after this release.

ACK to this patch too.

I really should run valgrind more often (used to do it all the time, but
I've fallen out of the habit...)





More information about the libvir-list mailing list