[libvirt] [PATCH] virscsi: Introduce virSCSIDeviceUsedByInfoFree
Ján Tomko
jtomko at redhat.com
Fri Mar 7 15:37:27 UTC 2014
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 at redhat.com>
> ---
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140307/6a6654c1/attachment-0001.sig>
More information about the libvir-list
mailing list