[libvirt] [PATCH 01/12] getstats: avoid memory leak on OOM
Peter Krempa
pkrempa at redhat.com
Mon Dec 8 10:50:26 UTC 2014
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141208/f3224ae8/attachment-0001.sig>
More information about the libvir-list
mailing list