> -----Original Message-----
> From: Wei Liu [mailto:wei.l...@citrix.com]
> Sent: 27 February 2017 12:20
> To: Xen-devel <xen-de...@lists.xenproject.org>
> Cc: Ian Jackson <ian.jack...@citrix.com>; Paul Durrant
> <paul.durr...@citrix.com>; Wei Liu <wei.l...@citrix.com>
> Subject: [PATCH] libs/devicemodel: free xencall handle in error path in
> _open()
> 
> Change the allocation to use calloc to get zeroed structure. Free
> xencall handler in error path.
> 
> Spotted by Coverity.
> 
> Signed-off-by: Wei Liu <wei.l...@citrix.com>

Reviewed-by: Paul Durrant <paul.durr...@citrix.com>

> ---
>  tools/libs/devicemodel/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> index 19ebef63b3..a85cb49c22 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -24,7 +24,7 @@
>  xendevicemodel_handle *xendevicemodel_open(xentoollog_logger
> *logger,
>                                             unsigned open_flags)
>  {
> -    xendevicemodel_handle *dmod = malloc(sizeof(*dmod));
> +    xendevicemodel_handle *dmod = calloc(1, sizeof(*dmod));
>      int rc;
> 
>      if (!dmod)
> @@ -54,6 +54,7 @@ xendevicemodel_handle
> *xendevicemodel_open(xentoollog_logger *logger,
> 
>  err:
>      xtl_logger_destroy(dmod->logger_tofree);
> +    xencall_close(dmod->xcall);
>      free(dmod);
>      return NULL;
>  }
> --
> 2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to