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

John Ferlan jferlan at redhat.com
Wed Mar 5 13:51:46 UTC 2014


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




More information about the libvir-list mailing list