Re: [PATCH v2] qemu: fix memory leak about virDomainEventTunableNew

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

 



On Fri, Sep 23, 2022 at 10:23:38 +0800, luzhipeng wrote:
> From: lu zhipeng <luzhipeng@xxxxxxxx>
> 
> For prevent memory leak and easier to use, So change
> virDomainEventTunableNew to get virTypedParameterPtr *params
> and set it = NULL.
> 
> Signed-off-by: lu zhipeng <luzhipeng@xxxxxxxx>
> ---
> v1: https://patchew.org/Libvirt/20220922130038.1616-1-luzhipeng@xxxxxxxx/
> 
>  src/conf/domain_event.c    | 12 ++++++------
>  src/conf/domain_event.h    |  4 ++--
>  src/qemu/qemu_driver.c     | 22 ++++++++++------------
>  src/remote/remote_driver.c |  2 +-
>  4 files changed, 19 insertions(+), 21 deletions(-)

Hmm, looks good, but I'm wondering what happened to your patch...

> diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
> index ff8ea2c389..97d58c2521 100644
> --- a/src/conf/domain_event.c
> +++ b/src/conf/domain_event.c
> @@ -1495,7 +1495,7 @@ static virObjectEvent *
>  virDomainEventTunableNew(int id,
>                           const char *name,
>                           unsigned char *uuid,
> -                         virTypedParameterPtr params,
> +                         virTypedParameterPtr *params,
>                           int nparams)
>  {
>      virDomainEventTunable *ev;
> @@ -1508,19 +1508,19 @@ virDomainEventTunableNew(int id,
>                                   id, name, uuid)))
>          goto error;
>  
> -    ev->params = params;
> +    ev->params = *params;
>      ev->nparams = nparams;
> -
> +    *params = NULL;
>      return (virObjectEvent *)ev;
>  
>   error:
> -    virTypedParamsFree(params, nparams);
> +    virTypedParamsFree(*params, nparams);
>      return NULL;
>  }
>  
>  virObjectEvent *
>  virDomainEventTunableNewFromObj(virDomainObj *obj,
> -                                virTypedParameterPtr params,
> +                                virTypedParameterPtr *params,
> 				 A

^^ "A" above

>                                  int nparams)
>  {
>      return virDomainEventTunableNew(obj->def->id,
> @@ -1532,7 +1532,7 @@ virDomainEventTunableNewFromObj(virDomainObj *obj,
>  
>  virObjectEvent *
>  virDomainEventTunableNewFromDom(virDomainPtr dom,
> -                                virTypedParameterPtr params,
> +                                virTypedParameterPtr *params,
>                                  int nparams)
>  {
>      return virDomainEventTunableNew(dom->id,
...
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 94b70872d4..3db4592945 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -4472,12 +4472,12 @@ qemuDomainPinVcpuLive(virDomainObj *vm,
>                                  &eventMaxparams, paramField, str) < 0)
>          goto cleanup;
>  
> -    event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
> A

again

> -
> +    event = virDomainEventTunableNewFromObj(vm, &eventParams, eventNparams);
>      ret = 0;
>  
>   cleanup:
>      virObjectEventStateQueue(driver->domainEventState, event);
> +    virTypedParamsFree(eventParams, eventNparams);
>      return ret;
>  }
>  
> @@ -4681,7 +4681,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
>                                      str) < 0)
>              goto endjob;
>  
> -        event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
> +        event = virDomainEventTunableNewFromDom(dom, &eventParams, eventNparams);
>      }
>  
>      if (persistentDef) {
> B
> A

and even more of it here

...

Jirka




[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