Re: [PATCH 3/3] xenconfig: Resolve Coverity RESOURCE_LEAK

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

 



On 22.08.2014 17:28, John Ferlan wrote:
Since '337a13628' - Coverity complains that 'net' is VIR_ALLOC()'d, but
on various 'cleanup' exit paths from the code there is no corresponding
cleanup.  Since 'net' is eventually appended onto a list of nets we don't
want to delete the last one - be sure to set it to NULL, but still call
the free function in cleanup

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
  src/xenconfig/xen_common.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 398e9ec..c487feb 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -949,6 +949,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)

              if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0)
                  goto cleanup;
+            net = NULL;

This is not needed. VIR_APPEND_ELEMENT() should clear out the @net variable. Or does coverity fail to see it?


          skipnic:
              list = list->next;
@@ -960,6 +961,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)
      return 0;

   cleanup:
+    virDomainNetDefFree(net);
      VIR_FREE(script);
      return -1;
  }


In fact this chunk alone should be enough.

Michal

--
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]