Re: [PATCH v14 01/49] virscsi: fix memory leak

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

 




On 03/07/2014 05:52 AM, Chunyan Liu wrote:
> Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
> ---
>  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

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