[libvirt] [PATCH] remoteNodeGetFreePages: Don't alloc args.pages.pages_val

Martin Kletzander mkletzan at redhat.com
Thu Sep 25 17:13:16 UTC 2014


On Thu, Sep 25, 2014 at 11:23:09AM +0200, Michal Privoznik wrote:
>There's no one to free() it anyway. Instead, we can just pass the
>provided array pointer directly.
>
>==20039== 48 bytes in 4 blocks are definitely lost in loss record 658 of 787
>==20039==    at 0x4C2A700: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
>==20039==    by 0x4EA661F: virAllocN (viralloc.c:191)
>==20039==    by 0x50386EF: remoteNodeGetFreePages (remote_driver.c:7625)
>==20039==    by 0x5003504: virNodeGetFreePages (libvirt.c:21379)
>==20039==    by 0x154625: cmdFreepages (virsh-host.c:374)
>==20039==    by 0x12F718: vshCommandRun (virsh.c:1935)
>==20039==    by 0x1339FB: main (virsh.c:3747)
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> src/remote/remote_driver.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>

ACK and valid for 1.2.9,

Martin

>diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
>index dc2d2fb..6c49e49 100644
>--- a/src/remote/remote_driver.c
>+++ b/src/remote/remote_driver.c
>@@ -7622,9 +7622,7 @@ remoteNodeGetFreePages(virConnectPtr conn,
>         goto done;
>     }
>
>-    if (VIR_ALLOC_N(args.pages.pages_val, npages) < 0)
>-        goto done;
>-    memcpy(args.pages.pages_val, pages, npages * sizeof(*pages));
>+    args.pages.pages_val = (u_int *) pages;
>     args.pages.pages_len = npages;
>     args.startCell = startCell;
>     args.cellCount = cellCount;
>--
>1.8.5.5
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- 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/20140925/f626f711/attachment-0001.sig>


More information about the libvir-list mailing list