From 65fc17d2f629317c1c4ec7b41109dcf6e3a95cd2 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Tue, 12 Feb 2019 07:00:38 -0500 Subject: [PATCH] storage: Fix error retval for getDeviceType MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/storage/storage_util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { -- 2.47.2