Re: [PATCH 5/6] xenconfig: Resolve Coverity RESOURCE_LEAK

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

 



On 01/09/2015 05:02 PM, John Ferlan wrote:
Commit id '2c78051a' added xenFormatXLDomainDisks which used the
virConfSetValue to set the 'diskVal' and handle/own the memory for
diskVal. However, if diskVal->list == NULL, the memory for diskVal
wouldn't be VIR_FREE()'d like other similar uses - so added the
VIR_FREE() to resolve the memory leak.

I also noted that the cleanup path should have returned -1 (like other
uses), so I modified that as well while I was making the change.

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

diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 8d1d2a7..45c479a 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -396,8 +396,7 @@ xenFormatXLDomainDisks(virConfPtr conf, virDomainDefPtr def)
          if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
              continue;
          if (xenFormatXLDisk(diskVal, def->disks[i]) < 0)
-
-                goto cleanup;
+            goto cleanup;
      }

      if (diskVal->list != NULL) {
@@ -407,11 +406,12 @@ xenFormatXLDomainDisks(virConfPtr conf, virDomainDefPtr def)
              goto cleanup;
      }

+    VIR_FREE(diskVal);
      return 0;

   cleanup:
      virConfFreeValue(diskVal);
-    return 0;
+    return -1;
  }




NACK to this one as it won't be necessary to fix this memory leak,
because the whole file will be removed by reverting the commit 2c78051a
by the new patch series to implement xl parser
<https://www.redhat.com/archives/libvir-list/2015-January/msg00268.html>.

Pavel

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