From: Wei Liu Subject: Re: [PATCH] Handles the error returned by the xc_dom_allocate function Date: Mon, 26 Oct 2015 10:40:18 +0000 Message-ID: <20151026104018.GQ5060@zion.uk.xensource.com> References: <1445767344-7780-1-git-send-email-comethalley61@gmail.com> <1445767344-7780-2-git-send-email-comethalley61@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZqfCQ-0006lj-Ia for xen-devel@lists.xenproject.org; Mon, 26 Oct 2015 10:40:22 +0000 Content-Disposition: inline In-Reply-To: <1445767344-7780-2-git-send-email-comethalley61@gmail.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: Lasya Venneti Cc: lars.kurth@citrix.com, stefano.stebellini@eu.citrix.com, wei.liu2@citrix.com, ian.campbell@citrix.com, dario.faggioli@citrix.com, george.dunlap@citrix.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org Aside from what Dario said. On Sun, Oct 25, 2015 at 03:32:24PM +0530, Lasya Venneti wrote: > --- > tools/xenstore/init-xenstore-domain.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/xenstore/init-xenstore-domain.c b/tools/xenstore/init-xenstore-domain.c > index 0d12169..d17aab5 100644 > --- a/tools/xenstore/init-xenstore-domain.c > +++ b/tools/xenstore/init-xenstore-domain.c > @@ -42,6 +42,8 @@ static int build(xc_interface *xch, int argc, char** argv) > snprintf(cmdline, 512, "--event %d --internal-db", rv); > > dom = xc_dom_allocate(xch, cmdline, NULL); > + if(dom==NULL) Coding style is wrong. It should be if (dom == NULL) Note the whitespaces. > + return -1; And, please set rv to a proper error code (presumably ENOMEM) and use goto err, otherwise you're leaking xs_fd. BTW I notice that xs_fd is leaked in success path. You can submit another path for it if you feel keen enough. Wei. > rv = xc_dom_kernel_file(dom, argv[1]); > if (rv) goto err; > > -- > 1.9.1