From 763b76cbf626f5ed851bbab85a922bfd8afdeb5e Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Mon, 11 Feb 2019 21:46:28 -0500 Subject: [PATCH] src: Fix label logic in virStorageBackendSCSITriggerRescan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/storage/storage_backend_scsi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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; }