xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 3/3] xl: create: close restore_fd_to_close on error
Date: Wed, 17 Feb 2016 14:04:15 +0000	[thread overview]
Message-ID: <1455717855-2344-3-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1455717855-2344-2-git-send-email-ian.campbell@citrix.com>

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>
---
 tools/libxl/xl_cmdimpl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 7ba40c0..514f5a8 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3069,6 +3069,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);
 
-- 
2.1.4

  reply	other threads:[~2016-02-17 14:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 14:04 [PATCH 1/3] xl: free config_data on error in domain_create Ian Campbell
2016-02-17 14:04 ` [PATCH 2/3] xl: use xrealloc in domain create Ian Campbell
2016-02-17 14:04   ` Ian Campbell [this message]
2016-02-19 16:04     ` [PATCH 3/3] xl: create: close restore_fd_to_close on error Ian Jackson
2016-02-19 16:03   ` [PATCH 2/3] xl: use xrealloc in domain create Ian Jackson
2016-02-19 16:02 ` [PATCH 1/3] xl: free config_data on error in domain_create Ian Jackson
2016-02-19 16:08   ` Ian Campbell
2016-02-19 16:10     ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455717855-2344-3-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).