]> xenbits.xensource.com Git - xen.git/commitdiff
tools/libxl: Fix free() of wild pointer in libxl__initiate_device_remove()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 Jun 2014 18:04:14 +0000 (19:04 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 23 Jun 2014 17:10:58 +0000 (18:10 +0100)
libxl__initiate_device_remove() had a preexisting error path issue where
libxl_dominfo_dispose() could be called on a libxl_dominfo object before it
had been initialised with libxl_dominfo_init().

This was safe until c/s ab44401 added the pointer ssid_label, which point
libxl_dominfo_dispose() free()s.

Unconditionally initialise info in libxl__initiate_device_remove() before
taking an error path which will free it.

Coverity-ID: 1223212
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/libxl/libxl_device.c

index 90ae564ffb43b27cdc20cf8416c7831a1d323543..788895b9b2aa86bd204ecfdfce9e8387f3461fa3 100644 (file)
@@ -772,6 +772,8 @@ void libxl__initiate_device_remove(libxl__egc *egc,
     uint32_t my_domid, domid = aodev->dev->domid;
     int rc = 0;
 
+    libxl_dominfo_init(&info);
+
     rc = libxl__get_domid(gc, &my_domid);
     if (rc) {
         LOG(ERROR, "unable to get my domid");
@@ -779,7 +781,6 @@ void libxl__initiate_device_remove(libxl__egc *egc,
     }
 
     if (my_domid == LIBXL_TOOLSTACK_DOMID) {
-        libxl_dominfo_init(&info);
         rc = libxl_domain_info(CTX, &info, domid);
         if (rc) {
             LOG(ERROR, "unable to get info for domain %d", domid);