]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: Alter return value of virReadFCHost and fix mem leak
authorJohn Ferlan <jferlan@redhat.com>
Tue, 11 Oct 2016 15:21:19 +0000 (11:21 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 14 Oct 2016 10:47:36 +0000 (06:47 -0400)
commitf29b13f8307985cffbd8a1a8c25bc4421db6f8a5
treebfabff8200a90e2f1330ab3648edb145f96bebc1
parent041dfc2b7d493a82f568ff54f670e29b9144c97f
util: Alter return value of virReadFCHost and fix mem leak

https://bugzilla.redhat.com/show_bug.cgi?id=1357416

Rather than return a 0 or -1 and the *result string, return just the result
string to the caller.  Alter all the callers to handle the different return.

As a side effect or result of this, it's much clearer that we cannot just
assign the returned string into the scsi_host wwnn, wwpn, and fabric_wwn
fields - rather we should fetch a temporary string, then as long as our
fetch was good, VIR_FREE what may have been there, and STEAL what we just got.
This fixes a memory leak in the virNodeDeviceCreateXML code path through
find_new_device and nodeDeviceLookupSCSIHostByWWN which will continually
call nodeDeviceSysfsGetSCSIHostCaps until the expected wwnn/wwpn is found
in the device object capabilities.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/node_device/node_device_linux_sysfs.c
src/util/virutil.c
src/util/virutil.h
tests/fchosttest.c