tools: libxl: do not leak diskpath during local disk attach
authorIan Campbell <ian.campbell@citrix.com>
Thu, 6 Nov 2014 13:00:31 +0000 (13:00 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 6 Nov 2014 16:30:47 +0000 (16:30 +0000)
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 <gedalya@gedalya.net>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl.c

index 7e7d1dff8fcdbdedffe03ea4fac52f69450d6097..f7961f608a864a7d287477bb49cf694b8bc3e999 100644 (file)
@@ -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;