[PATCH 6/6] EAFP: Coverity cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A new version of Coverity found:

get_dev_from_pool(): RESOURCE_LEAK
  - Because the code is run within a for() loop Coverity complains
    that the returned 'poolid' is not free'd during each pass through
    the loop.  So even though it may not be fetched again, just free()
    and reinitialize 'poolid' after usage

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/Virt_ElementAllocatedFromPool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c
index 03d856a..2c2f2d1 100644
--- a/src/Virt_ElementAllocatedFromPool.c
+++ b/src/Virt_ElementAllocatedFromPool.c
@@ -124,10 +124,14 @@ static CMPIStatus get_dev_from_pool(const CMPIObjectPath *ref,
                 poolid = pool_member_of(_BROKER, cn, type, dev_id);
                 if (poolid && STREQ(poolid, _poolid))
                         inst_list_add(list, inst);
+
+                if (poolid) {
+                    free(poolid);
+                    poolid = NULL;
+                }
         }
 
  out:
-        free(poolid);
         inst_list_free(&tmp);
 
         return s;
-- 
1.8.4.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]