From: Wei Liu Subject: Re: [PATCH 5/9] libxl: avoid leaking string in cpupool_info Date: Mon, 13 Jul 2015 17:24:50 +0100 Message-ID: <20150713162450.GS4108@zion.uk.xensource.com> References: <1436551257-28887-1-git-send-email-wei.liu2@citrix.com> <1436551257-28887-6-git-send-email-wei.liu2@citrix.com> <1436782051.7019.67.camel@citrix.com> <20150713161021.GR4108@zion.uk.xensource.com> <1436804590.25044.22.camel@citrix.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 1ZEgXj-0001sZ-Ln for xen-devel@lists.xenproject.org; Mon, 13 Jul 2015 16:25:23 +0000 Content-Disposition: inline In-Reply-To: <1436804590.25044.22.camel@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 Campbell Cc: Xen-devel , Wei Liu , Ian Jackson , Andrew Cooper List-Id: xen-devel@lists.xenproject.org On Mon, Jul 13, 2015 at 05:23:10PM +0100, Ian Campbell wrote: > On Mon, 2015-07-13 at 17:10 +0100, Wei Liu wrote: > > On Mon, Jul 13, 2015 at 11:07:31AM +0100, Ian Campbell wrote: > > > On Fri, 2015-07-10 at 19:00 +0100, Wei Liu wrote: > > > > Signed-off-by: Wei Liu > > > > > > Would an "if (rc) libxl_cpupoolinfo_dispose(info)" on the exit path be a > > > more robust alternative? Might require the addition of a > > > libxl_cpupoolinfo_init() somewhere before any possible error. > > > > > > > Yes, you're right, it would be better to fix the caller. > > I was suggesting to do it in this function, not the caller. > No, that's not right, that violates libxl calling style. The caller is supposed to call _init function before coming to this function. Wei. > > > > > This results in a larger patch than this one. I will send out the new > > version soon. > > > > Wei. > > > > > > --- > > > > tools/libxl/libxl.c | 4 +++- > > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > > > > index 38aff8d..4151dcb 100644 > > > > --- a/tools/libxl/libxl.c > > > > +++ b/tools/libxl/libxl.c > > > > @@ -740,8 +740,10 @@ static int cpupool_info(libxl__gc *gc, > > > > info->sched = xcinfo->sched_id; > > > > info->n_dom = xcinfo->n_dom; > > > > rc = libxl_cpu_bitmap_alloc(CTX, &info->cpumap, 0); > > > > - if (rc) > > > > + if (rc) { > > > > + free(info->pool_name); > > > > goto out; > > > > + } > > > > > > > > memcpy(info->cpumap.map, xcinfo->cpumap, info->cpumap.size); > > > > > > > >