On 12/06/14 09:14, Eric Blake wrote:
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(a)redhat.com>
---
src/qemu/qemu_driver.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9152cf5..a7b208f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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) \
@@ -18448,6 +18448,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver
ATTRIBUTE_UNUSED,
"tx.drop", tmp.tx_drop);
}
+ cleanup:
With this change qemuDomainGetStatsInterface will return success even in
case when the OOM occurred. You need to add a 'ret' variable set to -1
and set it to 0 just before cleanup, so that the error gets propagated.
return 0;
}
ACK if you keep reporting the error in OOM case in
qemuDomainGetStatsInterface()
Peter