From: Wei Liu Subject: Re: [PATCH 5/9] libxl: avoid leaking string in cpupool_info Date: Mon, 13 Jul 2015 17:10:21 +0100 Message-ID: <20150713161021.GR4108@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> 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 1ZEgJT-00086E-Aj for xen-devel@lists.xenproject.org; Mon, 13 Jul 2015 16:10:39 +0000 Content-Disposition: inline In-Reply-To: <1436782051.7019.67.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 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. 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); > > >