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

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



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 redhat com>
---
  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


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