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> --- 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