
On 03/07/2014 05:52 AM, Chunyan Liu wrote:
Signed-off-by: Chunyan Liu <cyliu@suse.com> --- src/util/virscsi.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 69eae24..627b3f8 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -296,12 +296,17 @@ virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev, virUsedByInfoPtr copy; if (VIR_ALLOC(copy) < 0) return -1; - if (VIR_STRDUP(copy->drvname, drvname) < 0) - return -1; - if (VIR_STRDUP(copy->domname, domname) < 0) - return -1; + if (VIR_STRDUP(copy->drvname, drvname) < 0 || + VIR_STRDUP(copy->domname, domname) < 0) + goto cleanup;
return VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy); + +cleanup: + VIR_FREE(copy->drvname); + VIR_FREE(copy->domname); + VIR_FREE(copy); + return -1; }
bool
This should be a separate patch as a result of : http://www.redhat.com/archives/libvir-list/2014-March/msg00282.html I also don't think this is the right way to fix it. See the following for what I think is a more appropriate way: http://www.redhat.com/archives/libvir-list/2014-March/msg00484.html John