Re: [PATCH] qemu: fix memory leak on some paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 22, 2022 at 04:26:06PM +0200, Jiri Denemark wrote:
On Thu, Sep 22, 2022 at 21:00:38 +0800, luzhipeng wrote:
From: lu zhipeng <luzhipeng@xxxxxxxx>

virTypedParamsAddString may return -1 but alloc params,
so free it.

Signed-off-by: lu zhipeng <luzhipeng@xxxxxxxx>
---
 src/qemu/qemu_driver.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 94b70872d4..c4501cd705 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4473,11 +4473,13 @@ qemuDomainPinVcpuLive(virDomainObj *vm,
         goto cleanup;

     event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);

This call consumes eventParams which should not be used afterwards. Thus
instead of

-
+    eventNparams = 0;

we should set eventParams = NULL here...

     ret = 0;

  cleanup:
     virObjectEventStateQueue(driver->domainEventState, event);

... and call virTypedParamsFree unconditionally.

+    if (eventNparams)
+        virTypedParamsFree(eventParams, eventNparams);
     return ret;
 }


Alternatively, virDomainEventTunableNew could be changed to get
virTypedParameterPtr *params and set &params = NULL itself.


That's what I wanted to suggest since it actually consumes the params as
it would make it more future-proof and easier to use.

Jirka

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux