block/qapi: Plug memory leak on query-block error path
PATCH 1/1 block/qapi: Plug memory leak on query-block error path
Spotted by Coverity.
Signed-off-by Markus Armbruster <[email protected]>
--- block/qapi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
block/qapi.c +3 -5
@@ -436,7 +436,9 @@ BlockInfoList *qmp_query_block(Error **errp)bdrv_query_info (blk, &info->value, &local_err);if (local_err) {error_propagate (errp, local_err); - goto err; +g_free (info); +qapi_free_BlockInfoList (head); +return NULL ; } *p_next = info;
@@ -444,10 +446,6 @@ BlockInfoList *qmp_query_block(Error **errp) }return head; - - err: -qapi_free_BlockInfoList (head); -return NULL ; } BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
Signature · 1 line
2.4.3
Quoted 12 lines · Markus Armbruster
Spotted by Coverity.
Signed-off-by Markus Armbruster <[email protected]>--- block/qapi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)block/qapi.c +0
-0
block/qapi.c BlockInfoList *qmp_query_block(Error **errp) · line 443
Quoted 9 lines
block/qapi.c +3
-1@@ -436,7 +436,9 @@ BlockInfoList *qmp_query_block(Error **errp)bdrv_query_info (blk, &info->value, &local_err);if (local_err) {error_propagate (errp, local_err); - goto err; +g_free (info); +qapi_free_BlockInfoList (head); +return NULL ; }
Only info was leaked, but inlining the entire 'err' label into its one use was easier than hoisting the declaration of info out of the loop.
Reviewed-by Eric Blake <[email protected]>
Quoted 13 lines
block/qapi.c +0
-4*p_next = info;@@ -444,10 +446,6 @@ BlockInfoList *qmp_query_block(Error **errp) }return head; - - err: -qapi_free_BlockInfoList (head); -return NULL ; } BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 1 line · Markus Armbruster
Spotted by Coverity.
Worth mentioning that commit 553a7e87 was the culprit.
Quoted 6 lines
Signed-off-by Markus Armbruster <[email protected]>--- block/qapi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Am 20.11.2015 um 13:53 hat Markus Armbruster geschrieben:
Quoted 3 lines
Spotted by Coverity.
Signed-off-by Markus Armbruster <[email protected]>
Reviewed-by Kevin Wolf <[email protected]>