mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
iscsi: Fix exit path for virStorageBackendISCSIFindLUs failure
If the call to virStorageBackendISCSIGetHostNumber failed, we set retval = -1, but yet still called virStorageBackendSCSIFindLUs. Need to add a goto cleanup - while at it, adjust the logic to initialize retval to -1 and only changed to 0 (zero) on success. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
d9ece06526
commit
f9efcd9218
@ -131,23 +131,27 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
|
|||||||
const char *session)
|
const char *session)
|
||||||
{
|
{
|
||||||
char *sysfs_path;
|
char *sysfs_path;
|
||||||
int retval = 0;
|
int retval = -1;
|
||||||
uint32_t host;
|
uint32_t host;
|
||||||
|
|
||||||
if (virAsprintf(&sysfs_path,
|
if (virAsprintf(&sysfs_path,
|
||||||
"/sys/class/iscsi_session/session%s/device", session) < 0)
|
"/sys/class/iscsi_session/session%s/device", session) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) {
|
if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to get host number for iSCSI session "
|
_("Failed to get host number for iSCSI session "
|
||||||
"with path '%s'"),
|
"with path '%s'"),
|
||||||
sysfs_path);
|
sysfs_path);
|
||||||
retval = -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStorageBackendSCSIFindLUs(pool, host) < 0)
|
if (virStorageBackendSCSIFindLUs(pool, host) < 0)
|
||||||
retval = -1;
|
goto cleanup;
|
||||||
|
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
|
||||||
VIR_FREE(sysfs_path);
|
VIR_FREE(sysfs_path);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user