Re: [PATCH] virscsi: Introduce virSCSIDeviceUsedByInfoFree

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

 



On 03/07/2014 03:55 PM, John Ferlan wrote:
> This resolves a Coverity RESOURCE_LEAK issue introduced by commit
> id 'de6fa535' where the virSCSIDeviceSetUsedBy() didn't VIR_FREE
> the 'copy' or possibly VIR_STRDUP()'d values.
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/util/virscsi.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 

> @@ -296,10 +301,11 @@ 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)
> +    if (VIR_STRDUP(copy->drvname, drvname) < 0 ||
> +        VIR_STRDUP(copy->domname, domname) < 0) {

> +        virSCSIDeviceUsedByInfoFree(copy);
>          return -1;

These two commands would look better in an error label

> +    }
>  
>      return VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy);

and copy should be freed even if VIR_APPEND_ELEMENT fails.

ACK with that fixed.

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

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