[libvirt] [PATCH] hyperv: Avoid Coverity warning about resource leak in hypervOpen

Coverity tagged the esxhypervPrivate pointer a potentially leaked because of the conditional free call. But this is a false positive, there is not actual leak. Avoid the conditial code to make this more obvious to Coverity. --- This patch is meant as a replacement for this patch https://www.redhat.com/archives/libvir-list/2013-January/msg00542.html src/hyperv/hyperv_driver.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 601a85a..0d2eaae 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -200,14 +200,11 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) } conn->privateData = priv; - + priv = NULL; result = VIR_DRV_OPEN_SUCCESS; cleanup: - if (result == VIR_DRV_OPEN_ERROR) { - hypervFreePrivate(&priv); - } - + hypervFreePrivate(&priv); VIR_FREE(username); VIR_FREE(password); hypervFreeObject(priv, (hypervObject *)computerSystem); -- 1.7.9.5

2013/1/10 Matthias Bolte <matthias.bolte@googlemail.com>:
Coverity tagged the esxhypervPrivate pointer a potentially leaked because of the conditional free call. But this is a false positive, there is not actual leak.
I've fix the s/esxhypervPrivate/hypervPrivate/ typo in my local repo. -- Matthias Bolte http://photron.blogspot.com

On 01/10/2013 02:48 PM, Matthias Bolte wrote:
Coverity tagged the esxhypervPrivate pointer a potentially leaked
You already fixed this typo..
because of the conditional free call. But this is a false positive, there is not actual leak.
Avoid the conditial code to make this more obvious to Coverity.
but be sure you also s/conditial/conditional/
---
This patch is meant as a replacement for this patch
https://www.redhat.com/archives/libvir-list/2013-January/msg00542.html
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

2013/1/10 Eric Blake <eblake@redhat.com>:
On 01/10/2013 02:48 PM, Matthias Bolte wrote:
Coverity tagged the esxhypervPrivate pointer a potentially leaked
You already fixed this typo..
because of the conditional free call. But this is a false positive, there is not actual leak.
Avoid the conditial code to make this more obvious to Coverity.
but be sure you also s/conditial/conditional/
---
This patch is meant as a replacement for this patch
https://www.redhat.com/archives/libvir-list/2013-January/msg00542.html
ACK.
As it turned out, the cause for the Coverity warning was in VIR_FREE. But I sill like the code simplification of this patch. So i updated the commit message and pushed it. Thanks. -- Matthias Bolte http://photron.blogspot.com
participants (2)
-
Eric Blake
-
Matthias Bolte