mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
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:
parent
9f019d0cfd
commit
2f61602edb
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user