Skip to content
Snippets Groups Projects
Commit f62492bb authored by Kevin Wolf's avatar Kevin Wolf
Browse files

block/qapi: Fix memory leak in qmp_query_blockstats()


For BlockBackends that are skipped in query-blockstats, we would leak
info since commit 567dcb31. Allocate info only later to avoid the memory
leak.

Fixes: CID 1394727
Cc: qemu-stable@nongnu.org
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
parent 38441756
No related branches found
No related tags found
No related merge requests found
......@@ -594,7 +594,7 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
}
} else {
for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
BlockStatsList *info = g_malloc0(sizeof(*info));
BlockStatsList *info;
AioContext *ctx = blk_get_aio_context(blk);
BlockStats *s;
char *qdev;
......@@ -619,6 +619,7 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
bdrv_query_blk_stats(s->stats, blk);
aio_context_release(ctx);
info = g_malloc0(sizeof(*info));
info->value = s;
*p_next = info;
p_next = &info->next;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment