From: John Ferlan Date: Tue, 12 Feb 2019 02:46:28 +0000 (-0500) Subject: src: Fix label logic in virStorageBackendSCSITriggerRescan X-Git-Tag: v5.1.0-rc1~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=763b76cbf626f5ed851bbab85a922bfd8afdeb5e;p=thirdparty%2Flibvirt.git src: Fix label logic in virStorageBackendSCSITriggerRescan Let's initialize @path to NULL, then rather than use two labels free_path and out labels, let's use the cleanup: label to call VIR_FREE(path); and VIR_FORCE_CLOSE(fd); Signed-off-by: John Ferlan Reviewed-by: Ján Tomko --- diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 14f01f9ec0..85a177865f 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -57,14 +57,14 @@ virStorageBackendSCSITriggerRescan(uint32_t host) { int fd = -1; int retval = 0; - char *path; + char *path = NULL; VIR_DEBUG("Triggering rescan of host %d", host); if (virAsprintf(&path, "%s/host%u/scan", LINUX_SYSFS_SCSI_HOST_PREFIX, host) < 0) { retval = -1; - goto out; + goto cleanup; } VIR_DEBUG("Scan trigger path is '%s'", path); @@ -76,23 +76,21 @@ virStorageBackendSCSITriggerRescan(uint32_t host) _("Could not open '%s' to trigger host scan"), path); retval = -1; - goto free_path; + goto cleanup; } if (safewrite(fd, LINUX_SYSFS_SCSI_HOST_SCAN_STRING, sizeof(LINUX_SYSFS_SCSI_HOST_SCAN_STRING)) < 0) { - VIR_FORCE_CLOSE(fd); virReportSystemError(errno, _("Write to '%s' to trigger host scan failed"), path); retval = -1; } + cleanup: VIR_FORCE_CLOSE(fd); - free_path: VIR_FREE(path); - out: VIR_DEBUG("Rescan of host %d complete", host); return retval; }