File 6718132d-use-cleanup-qemuProcessSEVCreateFile.patch of Package libvirt.9813

commit 6718132d785c8c07f1402fe89fd4ead99fa94895
Author: Ján Tomko <jtomko@redhat.com>
Date:   Tue Jun 12 13:39:42 2018 +0200

    qemuProcessSEVCreateFile: use a cleanup label
    
    A common cleanup path for both the success and the error case.
    
    Signed-off-by: Ján Tomko <jtomko@redhat.com>
    Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
    Tested-by: Brijesh Singh <brijesh.singh@amd.com>
    Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Index: libvirt-4.0.0/src/qemu/qemu_process.c
===================================================================
--- libvirt-4.0.0.orig/src/qemu/qemu_process.c
+++ libvirt-4.0.0/src/qemu/qemu_process.c
@@ -5588,6 +5588,7 @@ qemuProcessSEVCreateFile(const char *con
                          const char *data)
 {
     char *configFile;
+    int ret = -1;
 
     if (!(configFile = virFileBuildPath(configDir, name, ".base64")))
         return -1;
@@ -5595,15 +5596,12 @@ qemuProcessSEVCreateFile(const char *con
     if (virFileRewriteStr(configFile, S_IRUSR | S_IWUSR, data) < 0) {
         virReportSystemError(errno, _("failed to write data to config '%s'"),
                              configFile);
-        goto error;
+        goto cleanup;
     }
 
+ cleanup:
     VIR_FREE(configFile);
-    return 0;
-
- error:
-    VIR_FREE(configFile);
-    return -1;
+    return ret;
 }
 
 
openSUSE Build Service is sponsored by