From: Wei Liu Subject: Re: [PATCH] tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path Date: Tue, 17 Mar 2015 15:53:27 +0000 Message-ID: <20150317155327.GE20522@zion.uk.xensource.com> References: <1426500569-45595-1-git-send-email-koushik.chakravarty@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YXtoB-0008Bq-Px for xen-devel@lists.xenproject.org; Tue, 17 Mar 2015 15:53:31 +0000 Content-Disposition: inline In-Reply-To: <1426500569-45595-1-git-send-email-koushik.chakravarty@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: Koushik Chakravarty Cc: xen-devel@lists.xenproject.org, Wei Liu , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Mon, Mar 16, 2015 at 10:09:29AM +0000, Koushik Chakravarty wrote: > Signed-off-by: Koushik Chakravarty > CC: Ian Jackson > CC: Stefano Stabellini > CC: Ian Campbell > CC: Wei Liu > --- > tools/libxl/libxl_dm.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > index cb006df..161401c 100644 > --- a/tools/libxl/libxl_dm.c > +++ b/tools/libxl/libxl_dm.c > @@ -1508,7 +1508,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) > flexarray_t *dm_args; > char **args; > const char *dm; > - int logfile_w, null, rc; > + int logfile_w, null = -1, rc; > uint32_t domid = dmss->guest_domid; > > /* Always use qemu-xen as device model */ > @@ -1534,6 +1534,10 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) > goto error; > } > null = open("/dev/null", O_RDONLY); > + if (null < 0) { > + rc = ERROR_FAIL; > + goto error; > + } > > dmss->guest_config = NULL; > /* > @@ -1568,6 +1572,10 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) > > error: > assert(rc); > + if(logfile_w >= 0) > + close(logfile_w); > + if(null >= 0) > + close(null); Please add space between `if' and `('. Also you can just write if (logfile_w >= 0) close (logfile_w); if (null >= 0) close (null); Wei. > dmss->callback(egc, dmss, rc); > return; > } > -- > 1.7.10.4