From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH 5/9] libxl: avoid leaking string in cpupool_info Date: Mon, 13 Jul 2015 17:23:10 +0100 Message-ID: <1436804590.25044.22.camel@citrix.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> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZEgVf-00017D-Q5 for xen-devel@lists.xenproject.org; Mon, 13 Jul 2015 16:23:15 +0000 In-Reply-To: <20150713161021.GR4108@zion.uk.xensource.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: Wei Liu Cc: Xen-devel , Ian Jackson , Andrew Cooper List-Id: xen-devel@lists.xenproject.org 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. > > 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); > > > > >