mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-08 07:15:46 +00:00
conf: Cleanup matchFCHostToSCSIHost
Rather than the inlined VIR_FREE's, use a cleanup: label... Fixes an
issue introduced by 03346def
where @name was free'd before usage in
a virAsprintf to format scsi_host_name.
This commit is contained in:
parent
e22de286b1
commit
0a6cb28b9a
@ -2341,6 +2341,7 @@ matchFCHostToSCSIHost(virConnectPtr conn,
|
|||||||
virStoragePoolSourceAdapter fc_adapter,
|
virStoragePoolSourceAdapter fc_adapter,
|
||||||
unsigned int scsi_hostnum)
|
unsigned int scsi_hostnum)
|
||||||
{
|
{
|
||||||
|
bool ret = false;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char *scsi_host_name = NULL;
|
char *scsi_host_name = NULL;
|
||||||
char *parent_name = NULL;
|
char *parent_name = NULL;
|
||||||
@ -2362,10 +2363,9 @@ matchFCHostToSCSIHost(virConnectPtr conn,
|
|||||||
* matches our scsi_hostnum
|
* matches our scsi_hostnum
|
||||||
*/
|
*/
|
||||||
if (virStorageIsSameHostnum(name, scsi_hostnum)) {
|
if (virStorageIsSameHostnum(name, scsi_hostnum)) {
|
||||||
VIR_FREE(name);
|
ret = true;
|
||||||
return true;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(name);
|
|
||||||
|
|
||||||
/* We weren't provided a parent, so we have to query the node
|
/* We weren't provided a parent, so we have to query the node
|
||||||
* device driver in order to ascertain the parent of the vHBA.
|
* device driver in order to ascertain the parent of the vHBA.
|
||||||
@ -2373,23 +2373,18 @@ matchFCHostToSCSIHost(virConnectPtr conn,
|
|||||||
* have a match.
|
* have a match.
|
||||||
*/
|
*/
|
||||||
if (conn && !fc_adapter.data.fchost.parent) {
|
if (conn && !fc_adapter.data.fchost.parent) {
|
||||||
if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) {
|
if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
|
||||||
VIR_FREE(name);
|
goto cleanup;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((parent_name = virNodeDeviceGetParentName(conn,
|
if ((parent_name = virNodeDeviceGetParentName(conn,
|
||||||
scsi_host_name))) {
|
scsi_host_name))) {
|
||||||
VIR_FREE(scsi_host_name);
|
|
||||||
if (virStorageIsSameHostnum(parent_name, scsi_hostnum)) {
|
if (virStorageIsSameHostnum(parent_name, scsi_hostnum)) {
|
||||||
VIR_FREE(parent_name);
|
ret = true;
|
||||||
return true;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(parent_name);
|
|
||||||
} else {
|
} else {
|
||||||
/* Throw away the error and fall through */
|
/* Throw away the error and fall through */
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
VIR_DEBUG("Could not determine parent vHBA");
|
VIR_DEBUG("Could not determine parent vHBA");
|
||||||
VIR_FREE(scsi_host_name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2401,7 +2396,12 @@ matchFCHostToSCSIHost(virConnectPtr conn,
|
|||||||
* conflict with an existing scsi_host definition, but there's no
|
* conflict with an existing scsi_host definition, but there's no
|
||||||
* way to know that now.
|
* way to know that now.
|
||||||
*/
|
*/
|
||||||
return false;
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(name);
|
||||||
|
VIR_FREE(parent_name);
|
||||||
|
VIR_FREE(scsi_host_name);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
Loading…
Reference in New Issue
Block a user