Skip to contentSkip to conversation

: QEMU: Additional error checking in Cirrus setup

PATCH New Chris Lalancette 1 participant 1 message Aug 24, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : QEMU: Additional error checking in Cirrus setup

All,
Attached is a patch to do some additional error checking in QEMU when
setting up the Cirrus Logic video device. In particular, it may be the case that that set_mm_mapping() fails because of xc_domain_populate_physmap(). In this case, we should not blindly go on; the xc_map_foreign_batch() that follows will cause a page fault and, at best, get mapped in a zeroed page from the dom0 (which is not what we want). While I'm in here, fix a memory leak on an error path.

The patch is against 3.1.0, but should apply fairly easily to xen-unstable.

tools/ioemu/hw/cirrus_vga.c +6 -1
diff -urp xen-3.1.0-src.orig/tools/ioemu/hw/cirrus_vga.c xen-3.1.0-src/tools/ioemu/hw/cirrus_vga.c
@@ -2554,7 +2554,11 @@ static void *set_vram_mapping(unsigned l
     for (i = 0; i < nr_extents; i++)
         extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS;
 
-    set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
+    if (set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start) < 0) {
+        fprintf(logfile, "Failed set_mm_mapping\n");
+        free(extent_start);
+        return NULL;
+    }
 
     vram_pointer = xc_map_foreign_batch(xc_handle, domid,
                                         PROT_READ|PROT_WRITE,
@@ -2562,6 +2566,7 @@ static void *set_vram_mapping(unsigned l
     if (vram_pointer == NULL) {
         fprintf(logfile, "xc_map_foreign_batch vgaram returned error %d\n",
                 errno);
+        free(extent_start);
         return NULL;
     }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel