]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Fix error retval for getDeviceType
authorJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 12:00:38 +0000 (07:00 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 13:51:23 +0000 (08:51 -0500)
On error from virAsprintf we would erroneously return 0 with
the @*type not being set. Change to a return -1 on error like
we should have been doing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage/storage_util.c

index e4913b3405c00f664aef98c006f3ea3713b950cb..49f0d9d1f29b41346d089d931f04f09b78e8538c 100644 (file)
@@ -4044,8 +4044,10 @@ getDeviceType(uint32_t host,
     int retval = 0;
 
     if (virAsprintf(&type_path, "/sys/bus/scsi/devices/%u:%u:%u:%u/type",
-                    host, bus, target, lun) < 0)
+                    host, bus, target, lun) < 0) {
+        retval = -1;
         goto out;
+    }
 
     typefile = fopen(type_path, "r");
     if (typefile == NULL) {