From: John Ferlan Date: Tue, 12 Feb 2019 12:00:38 +0000 (-0500) Subject: storage: Fix error retval for getDeviceType X-Git-Tag: v5.1.0-rc1~129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65fc17d2f629317c1c4ec7b41109dcf6e3a95cd2;p=thirdparty%2Flibvirt.git storage: Fix error retval for getDeviceType 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 Reviewed-by: Ján Tomko --- diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index e4913b3405..49f0d9d1f2 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -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) {