[libvirt] [PATCH 3/3] virQEMUCapsSetHostModel: Free cpuData before setting it

Peter Krempa pkrempa at redhat.com
Wed May 30 16:57:11 UTC 2018


On Wed, May 30, 2018 at 18:04:29 +0200, Michal Privoznik wrote:
> While this leak happens in tests only, it is still worth fixing.
> 
> ==12962== 2,035 (104 direct, 1,931 indirect) bytes in 1 blocks are definitely lost in loss record 325 of 331
> ==12962==    at 0x4C2CF26: calloc (vg_replace_malloc.c:711)
> ==12962==    by 0x5D285D5: virAlloc (viralloc.c:144)
> ==12962==    by 0x5E823EB: virCPUGetHost (cpu.c:411)
> ==12962==    by 0x56DE953: virQEMUCapsInitHostCPUModel (qemu_capabilities.c:2874)
> ==12962==    by 0x56E062F: virQEMUCapsLoadCache (qemu_capabilities.c:3435)
> ==12962==    by 0x13802F: qemuTestParseCapabilitiesArch (testutilsqemu.c:500)
> ==12962==    by 0x1371F0: mymain (qemuxml2argvtest.c:2871)
> ==12962==    by 0x13AD0B: virTestMain (testutils.c:1120)
> ==12962==    by 0x1372FD: main (qemuxml2argvtest.c:2883)
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index e2e76e4dd8..9ec9089d5b 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -1857,6 +1857,10 @@ virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
>  {
>      virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
>  
> +    virCPUDefFree(cpuData->reported);
> +    virCPUDefFree(cpuData->migratable);
> +    virCPUDefFree(cpuData->full);

This looks fishy. The test code always unrefs the qemuCaps object, so
there should be no leak. Could you please elaborate on how this happens?

My problem is that this is in the setter code.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180530/f4d6ad85/attachment-0001.sig>


More information about the libvir-list mailing list