Re: [PATCH v2] daemon: Fix domain name leak in error path

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

 




On 04/16/2017 11:32 PM, Wang King wrote:
> Domain name duplicated in make_nonnull_domain, but not freed when virTypedParamsSerialize
> return negative.
> 
> Remove useless error label incidentally.
> ---
>  daemon/remote.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 

I had hoped for separate patches - one to remove unnecessary goto error
and the other to ensure the free is done.  You could almost make 4
patches out of this, but 2 would be sufficient.

They are different issues and thus should have separate patches.

John
> diff --git a/daemon/remote.c b/daemon/remote.c
> index 1610fea..d8a55c7 100644
> --- a/daemon/remote.c
> +++ b/daemon/remote.c
> @@ -648,7 +648,7 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn,
>      /* build return data */
>      memset(&data, 0, sizeof(data));
>      if (VIR_STRDUP(data.path, path) < 0)
> -        goto error;
> +        return -1;
>      data.type = type;
>      data.status = status;
>      make_nonnull_domain(&data.dom, dom);
> @@ -667,9 +667,6 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn,
>      }
>  
>      return 0;
> - error:
> -    VIR_FREE(data.path);
> -    return -1;
>  }
>  
>  
> @@ -1025,7 +1022,7 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
>      memset(&data, 0, sizeof(data));
>      data.callbackID = callback->callbackID;
>      if (VIR_STRDUP(data.dst, dst) < 0)
> -        goto error;
> +        return -1;
>      data.type = type;
>      data.status = status;
>      make_nonnull_domain(&data.dom, dom);
> @@ -1035,9 +1032,6 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
>                                    (xdrproc_t)xdr_remote_domain_event_block_job_2_msg, &data);
>  
>      return 0;
> - error:
> -    VIR_FREE(data.dst);
> -    return -1;
>  }
>  
>  
> @@ -1067,7 +1061,7 @@ remoteRelayDomainEventTunable(virConnectPtr conn,
>                                  (virTypedParameterRemotePtr *) &data.params.params_val,
>                                  &data.params.params_len,
>                                  VIR_TYPED_PARAM_STRING_OKAY) < 0)
> -        return -1;
> +        goto error;
>  
>      remoteDispatchObjectEventSend(callback->client, remoteProgram,
>                                    REMOTE_PROC_DOMAIN_EVENT_CALLBACK_TUNABLE,
> @@ -1075,6 +1069,10 @@ remoteRelayDomainEventTunable(virConnectPtr conn,
>                                    &data);
>  
>      return 0;
> + error:
> +    VIR_FREE(data.dom.name);
> +    return -1;
> +
>  }
>  
>  
> @@ -1207,13 +1205,16 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn,
>                                  (virTypedParameterRemotePtr *) &data.params.params_val,
>                                  &data.params.params_len,
>                                  VIR_TYPED_PARAM_STRING_OKAY) < 0)
> -        return -1;
> +        goto error;
>  
>      remoteDispatchObjectEventSend(callback->client, remoteProgram,
>                                    REMOTE_PROC_DOMAIN_EVENT_CALLBACK_JOB_COMPLETED,
>                                    (xdrproc_t)xdr_remote_domain_event_callback_job_completed_msg,
>                                    &data);
>      return 0;
> + error:
> +    VIR_FREE(data.dom.name);
> +    return -1;
>  }
>  
>  
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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