From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: [PATCH 3/3] xl: create: close restore_fd_to_close on error Date: Wed, 17 Feb 2016 14:04:15 +0000 Message-ID: <1455717855-2344-3-git-send-email-ian.campbell@citrix.com> References: <1455717855-2344-1-git-send-email-ian.campbell@citrix.com> <1455717855-2344-2-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1455717855-2344-2-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, xen-devel@lists.xen.org Cc: Ian Campbell List-Id: xen-devel@lists.xenproject.org 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 --- 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