[libvirt] [PATCH 01/12] getstats: avoid memory leak on OOM
Eric Blake
eblake at redhat.com
Mon Dec 8 16:44:20 UTC 2014
On 12/08/2014 03:50 AM, Peter Krempa wrote:
> 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 :)
>> + 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.
Oh right :)
>
> ACK if you keep reporting the error in OOM case in
> qemuDomainGetStatsInterface()
Done and pushed:
diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c
index a7b208f..ed8e140 100644
--- i/src/qemu/qemu_driver.c
+++ w/src/qemu/qemu_driver.c
@@ -18409,6 +18409,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr
driver ATTRIBUTE_UNUSED,
{
size_t i;
struct _virDomainInterfaceStats tmp;
+ int ret = -1;
if (!virDomainObjIsActive(dom))
return 0;
@@ -18448,8 +18449,9 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr
driver ATTRIBUTE_UNUSED,
"tx.drop", tmp.tx_drop);
}
+ ret = 0;
cleanup:
- return 0;
+ return ret;
}
#undef QEMU_ADD_NET_PARAM
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141208/3a74a540/attachment-0001.sig>
More information about the libvir-list
mailing list