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(a)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