qemuMonitorGetAllBlockStatsInfo: Assign hash table only on success

`virHashNew` cannot return NULL, the check is not needed.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-07-06 14:37:51 +02:00 committed by Michal Privoznik
parent 31678663b3
commit 00a7e385f1
1 changed files with 5 additions and 3 deletions

View File

@ -2155,22 +2155,24 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitor *mon,
bool backingChain)
{
int ret;
GHashTable *stats = NULL;
VIR_DEBUG("ret_stats=%p, backing=%d", ret_stats, backingChain);
QEMU_CHECK_MONITOR(mon);
if (!(*ret_stats = virHashNew(g_free)))
if (!(stats = virHashNew(g_free)))
goto error;
ret = qemuMonitorJSONGetAllBlockStatsInfo(mon, *ret_stats, backingChain);
ret = qemuMonitorJSONGetAllBlockStatsInfo(mon, stats, backingChain);
if (ret < 0)
goto error;
*ret_stats = stats;
return ret;
error:
virHashFree(*ret_stats);
virHashFree(stats);
*ret_stats = NULL;
return -1;
}