libs/devicemodel: free xencall handle in error path in _open()
PATCH 1/1 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.
--- tools/libs/devicemodel/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libs/devicemodel/core.c +2 -1
@@ -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 ; }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 9 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 27 February 2017 12:20
To: Xen-devel <[email protected]>
Cc: Ian Jackson <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>
Subject: [PATCH] libs/devicemodel: free xencall handle in error path in_open()
Quoted 6 lines
Change the allocation to use calloc to get zeroed structure. Free xencall handler in error path.
Spotted by Coverity.
Signed-off-by Wei Liu <[email protected]>
Quoted 26 lines
--- tools/libs/devicemodel/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/libs/devicemodel/core.c +1
-1@@ -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)tools/libs/devicemodel/core.c +1
-0@@ -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 ;
Quoted 3 lines
}
--
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Wei Liu writes ("[PATCH] libs/devicemodel: free xencall handle in error path in _open()"):
Quoted 4 lines
Change the allocation to use calloc to get zeroed structure. Free xencall handler in error path.
Spotted by Coverity.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel