|
|
9119d9 |
From d5ce6b8bd0ae390ceb6311030d41889b7e6cd9f7 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <d5ce6b8bd0ae390ceb6311030d41889b7e6cd9f7@dist-git>
|
|
|
9119d9 |
From: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
Date: Wed, 17 Dec 2014 03:08:59 -0700
|
|
|
9119d9 |
Subject: [PATCH] getstats: avoid memory leak on OOM
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1041569
|
|
|
9119d9 |
|
|
|
9119d9 |
qemuDomainGetStatsBlock() could leak a stats hash table if it
|
|
|
9119d9 |
encountered OOM while populating the virTypedParameters.
|
|
|
9119d9 |
Oddly, the fix doesn't even touch qemuDomainGetStatsBlock :)
|
|
|
9119d9 |
|
|
|
9119d9 |
* src/qemu/qemu_driver.c (QEMU_ADD_COUNT_PARAM)
|
|
|
9119d9 |
(QEMU_ADD_NAME_PARAM): Don't return early.
|
|
|
9119d9 |
(qemuDomainGetStatsInterface): Adjust caller.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 2f61602edbc96309116d7c8eff61e6a37ff4d253)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_driver.c | 9 ++++++---
|
|
|
9119d9 |
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
index 4498194..33a93f1 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_driver.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
@@ -17895,7 +17895,7 @@ do { \
|
|
|
9119d9 |
maxparams, \
|
|
|
9119d9 |
param_name, \
|
|
|
9119d9 |
count) < 0) \
|
|
|
9119d9 |
- return -1; \
|
|
|
9119d9 |
+ goto cleanup; \
|
|
|
9119d9 |
} while (0)
|
|
|
9119d9 |
|
|
|
9119d9 |
#define QEMU_ADD_NAME_PARAM(record, maxparams, type, num, name) \
|
|
|
9119d9 |
@@ -17908,7 +17908,7 @@ do { \
|
|
|
9119d9 |
maxparams, \
|
|
|
9119d9 |
param_name, \
|
|
|
9119d9 |
name) < 0) \
|
|
|
9119d9 |
- return -1; \
|
|
|
9119d9 |
+ goto cleanup; \
|
|
|
9119d9 |
} while (0)
|
|
|
9119d9 |
|
|
|
9119d9 |
#define QEMU_ADD_NET_PARAM(record, maxparams, num, name, value) \
|
|
|
9119d9 |
@@ -17933,6 +17933,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
{
|
|
|
9119d9 |
size_t i;
|
|
|
9119d9 |
struct _virDomainInterfaceStats tmp;
|
|
|
9119d9 |
+ int ret = -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (!virDomainObjIsActive(dom))
|
|
|
9119d9 |
return 0;
|
|
|
9119d9 |
@@ -17972,7 +17973,9 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
"tx.drop", tmp.tx_drop);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- return 0;
|
|
|
9119d9 |
+ ret = 0;
|
|
|
9119d9 |
+ cleanup:
|
|
|
9119d9 |
+ return ret;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
#undef QEMU_ADD_NET_PARAM
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.0
|
|
|
9119d9 |
|