getstats: avoid memory leak on OOM

qemuDomainGetStatsBlock() could leak a stats hash table if it
encountered OOM while populating the virTypedParameters.
Oddly, the fix doesn't even touch qemuDomainGetStatsBlock :)

* src/qemu/qemu_driver.c (QEMU_ADD_COUNT_PARAM)
(QEMU_ADD_NAME_PARAM): Don't return early.
(qemuDomainGetStatsInterface): Adjust caller.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-12-05 16:06:52 -07:00
parent 9f019d0cfd
commit 2f61602edb

View File

@ -18371,7 +18371,7 @@ do { \
maxparams, \
param_name, \
count) < 0) \
return -1; \
goto cleanup; \
} while (0)
#define QEMU_ADD_NAME_PARAM(record, maxparams, type, num, name) \
@ -18384,7 +18384,7 @@ do { \
maxparams, \
param_name, \
name) < 0) \
return -1; \
goto cleanup; \
} while (0)
#define QEMU_ADD_NET_PARAM(record, maxparams, num, name, value) \
@ -18409,6 +18409,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
{
size_t i;
struct _virDomainInterfaceStats tmp;
int ret = -1;
if (!virDomainObjIsActive(dom))
return 0;
@ -18448,7 +18449,9 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
"tx.drop", tmp.tx_drop);
}
return 0;
ret = 0;
cleanup:
return ret;
}
#undef QEMU_ADD_NET_PARAM