summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForest Bond <forest@alittletooquiet.net>2011-03-22 10:31:43 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2011-03-22 14:44:25 +0000
commitd641f0fd42c2f59459641f039a8da7d3b2adbae8 (patch)
tree40e2bf6662daee0310cb30edd48a2160f0afb14d
parent3f10ff85bd2bb65e49e52ec4f025dc977985b4b6 (diff)
intel_bios_dumper: handle rom_size == 0
Some versions of libpciaccess on Linux set rom_size to 0 for VGA devices. While this behavior may change, intel_bios_dumper should handle this situation to be compatible with current versions of the library. This fixes segmentation faults on affected systems. Signed-off-by: Forest Bond <forest.bond@rapidrollout.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--tools/intel_bios_dumper.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/intel_bios_dumper.c b/tools/intel_bios_dumper.c
index 53293ebd..0fa18339 100644
--- a/tools/intel_bios_dumper.c
+++ b/tools/intel_bios_dumper.c
@@ -77,6 +77,11 @@ int main(int argc, char **argv)
if (dev->vendor_id != 0x8086)
errx(1, "Graphics card is non-intel");
+ /* Some versions of libpciaccess correct this automatically, but some
+ * don't. */
+ if (dev->rom_size == 0)
+ dev->rom_size = 64 * 1024;
+
bios = malloc(dev->rom_size);
if (bios == NULL)
errx(1, "Couldn't allocate memory for BIOS data\n");