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(a)redhat.com>
---
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;
}
--
2.1.0