ia64/xen-unstable

changeset 15787:7f53312a3297

ioemu: error checkin when setting up the Cirrus Logic video device.

set_mm_mapping() may fail 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.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
author kfraser@localhost.localdomain
date Tue Aug 28 16:08:38 2007 +0100 (2007-08-28)
parents 505021d029eb
children 8e3abd893835
files tools/ioemu/hw/cirrus_vga.c
line diff
     1.1 --- a/tools/ioemu/hw/cirrus_vga.c	Tue Aug 28 16:06:32 2007 +0100
     1.2 +++ b/tools/ioemu/hw/cirrus_vga.c	Tue Aug 28 16:08:38 2007 +0100
     1.3 @@ -2559,7 +2559,11 @@ static void *set_vram_mapping(unsigned l
     1.4      for (i = 0; i < nr_extents; i++)
     1.5          extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS;
     1.6  
     1.7 -    set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
     1.8 +    if (set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start) < 0) {
     1.9 +        fprintf(logfile, "Failed set_mm_mapping\n");
    1.10 +        free(extent_start);
    1.11 +        return NULL;
    1.12 +    }
    1.13  
    1.14      vram_pointer = xc_map_foreign_batch(xc_handle, domid,
    1.15                                          PROT_READ|PROT_WRITE,
    1.16 @@ -2567,6 +2571,7 @@ static void *set_vram_mapping(unsigned l
    1.17      if (vram_pointer == NULL) {
    1.18          fprintf(logfile, "xc_map_foreign_batch vgaram returned error %d\n",
    1.19                  errno);
    1.20 +        free(extent_start);
    1.21          return NULL;
    1.22      }
    1.23