]> xenbits.xensource.com Git - libvirt.git/commitdiff
iscsi: Fix exit path for virStorageBackendISCSIFindLUs failure
authorJohn Ferlan <jferlan@redhat.com>
Wed, 1 Apr 2015 10:46:25 +0000 (06:46 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 2 Apr 2015 12:46:26 +0000 (08:46 -0400)
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>
src/storage/storage_backend_iscsi.c

index 0c225b05ad99e5494ffb79731c1c541ce1abdb17..197d33381f6374f339681e45d9c47484a812b14d 100644 (file)
@@ -131,23 +131,27 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
                               const char *session)
 {
     char *sysfs_path;
-    int retval = 0;
+    int retval = -1;
     uint32_t host;
 
     if (virAsprintf(&sysfs_path,
                     "/sys/class/iscsi_session/session%s/device", session) < 0)
-        return -1;
+        goto cleanup;
 
     if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) {
         virReportSystemError(errno,
                              _("Failed to get host number for iSCSI session "
                                "with path '%s'"),
                              sysfs_path);
-        retval = -1;
+        goto cleanup;
     }
 
     if (virStorageBackendSCSIFindLUs(pool, host) < 0)
-        retval = -1;
+        goto cleanup;
+
+    retval = 0;
+
+ cleanup:
 
     VIR_FREE(sysfs_path);