]> xenbits.xensource.com Git - xen.git/commitdiff
xl: create: close restore_fd_to_close on error
authorIan Campbell <ian.campbell@citrix.com>
Wed, 17 Feb 2016 14:04:15 +0000 (14:04 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 19 Feb 2016 16:03:53 +0000 (16:03 +0000)
Currently the fd is opened and then later closed and
restore_fd_to_close set back to -1, however there are several goto out
and goto error_out paths in the interim.

Since the code resets restore_fd_to_close to -1 it is OK to check this
and close on the out path too.

CID: 1055897

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c

index 2271e757c18dd8e70ae02a7f3a6b55a733236617..f40af51779a6c7b3c8242d6103fba6fd59c1d2f0 100644 (file)
@@ -3063,6 +3063,13 @@ error_out:
     }
 
 out:
+    if (restore_fd_to_close >= 0) {
+        if (close(restore_fd_to_close))
+            fprintf(stderr, "Failed to close restoring file, fd %d, errno %d\n",
+                    restore_fd_to_close, errno);
+        restore_fd_to_close = -1;
+    }
+
     if (logfile != 2)
         close(logfile);