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.liu2@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
Wei Liu committed 2017-02-27 16:33:56 +00:00
1 parent 0003cf2a53
commit f68c7c618a
1 file changed
+2 -1
+2 -1
View File
@@ -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;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.