From: Ian Jackson Subject: Re: [PATCH] tools: libxl: do not leak diskpath during local disk attach Date: Thu, 6 Nov 2014 16:28:28 +0000 Message-ID: <21595.41388.814871.925485@mariner.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: 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, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("[PATCH] tools: libxl: do not leak diskpath during local disk attach"): > 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: Ian Jackson This patch is correct. Apropos of your question on IRC, it is correct to use `gc', which is the gc from the ao. Its lifetime is the whole device creation operation, which is fine. You sometimes (including here) don't want to use the egc's gc in an ao operation, because its lifetime is just the current event callback. This is why we have STATE_AO_GC at the top of these functions, to make sure `gc' is simply the right gc. I will apply this patch to staging and queue it for backport. Ian.