]> git.proxmox.com Git - qemu.git/commitdiff
pc_sysfw: Fix ISA BIOS init for ridiculously big flash
authorMarkus Armbruster <armbru@redhat.com>
Wed, 31 Jul 2013 13:11:12 +0000 (15:11 +0200)
committerAnthony Liguori <anthony@codemonkey.ws>
Thu, 12 Sep 2013 16:45:32 +0000 (11:45 -0500)
pc_isa_bios_init() suffers integer overflow for flash larger than
INT_MAX.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 1375276272-15988-9-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
hw/i386/pc_sysfw.c

index 8246a1bdd499fea325541bd760aafcf02f2e7530..e917c83540fc3e9adbfbee8648ccca6d550d6823 100644 (file)
@@ -53,10 +53,7 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory,
     flash_size = memory_region_size(flash_mem);
 
     /* map the last 128KB of the BIOS in ISA space */
-    isa_bios_size = flash_size;
-    if (isa_bios_size > (128 * 1024)) {
-        isa_bios_size = 128 * 1024;
-    }
+    isa_bios_size = MIN(flash_size, 128 * 1024);
     isa_bios = g_malloc(sizeof(*isa_bios));
     memory_region_init_ram(isa_bios, NULL, "isa-bios", isa_bios_size);
     vmstate_register_ram_global(isa_bios);