Re: [PATCH v13 01/49] add 'driver' info to used_by

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

 



Coverity found a memory leak...

<...snip...>

>  int
>  virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev,
> -                       const char *name)
> +                       const char *drvname,
> +                       const char *domname)
>  {
> -    char *copy = NULL;
> -
> -    if (VIR_STRDUP(copy, name) < 0)
> +    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;

Either/both VIR_STRDUP() failures of return -1 will leak 'copy'.

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]