[PATCH 5/6] RAFP: Coverity cleanup

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

 



A new version of Coverity found:

filter_by_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_ResourceAllocationFromPool.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/Virt_ResourceAllocationFromPool.c b/src/Virt_ResourceAllocationFromPool.c
index 7088900..7bee729 100644
--- a/src/Virt_ResourceAllocationFromPool.c
+++ b/src/Virt_ResourceAllocationFromPool.c
@@ -120,9 +120,12 @@ static int filter_by_pool(struct inst_list *dest,
                 poolid = pool_member_of(_BROKER, CLASSNAME(op), type, rasd_id);
                 if ((poolid != NULL) && STREQ(poolid, _poolid))
                         inst_list_add(dest, inst);
-        }
 
-        free(poolid);
+                if (poolid != NULL) {
+                        free(poolid);
+                        poolid = NULL;
+                }
+        }
 
         return dest->cur;
 }
-- 
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]