From: Wei Liu Subject: Re: [PATCH] tools: libxl: do not leak diskpath during local disk attach Date: Thu, 6 Nov 2014 13:04:05 +0000 Message-ID: <20141106130405.GA2580@zion.uk.xensource.com> References: <1415278831-9249-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1415278831-9249-1-git-send-email-ian.campbell@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: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, Nov 06, 2014 at 01:00:31PM +0000, Ian Campbell wrote: > libxl__device_disk_local_initiate_attach is assigning dls->diskpath with a > strdup of the device path. This is then passed to the callback, e.g. > parse_bootloader_result but bootloader_cleanup will not free it. > > Since the callback is within the scope of the (e)gc and therefore doesn't need > to be malloc'd, a gc'd alloc will do. All other assignments to this field use > the gc. > > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=767295 > > Reported-by: Gedalya > Signed-off-by: Ian Campbell Acked-by: Wei Liu > --- > This is a bug fix for 4.5. > > This fix should be queued for backporting to at least 4.4 > --- > tools/libxl/libxl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index 18561fb..e76d898 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -3030,7 +3030,7 @@ void libxl__device_disk_local_initiate_attach(libxl__egc *egc, > } > > if (dev != NULL) > - dls->diskpath = strdup(dev); > + dls->diskpath = libxl__strdup(gc, dev); > > dls->callback(egc, dls, 0); > return; > -- > 1.7.10.4