diff -up libpciaccess-0.10.6/src/linux_devmem.c.jx libpciaccess-0.10.6/src/linux_devmem.c --- libpciaccess-0.10.6/src/linux_devmem.c.jx 2008-10-15 18:35:54.000000000 -0400 +++ libpciaccess-0.10.6/src/linux_devmem.c 2009-08-05 11:43:14.000000000 -0400 @@ -50,6 +50,30 @@ #include "pciaccess_private.h" #include "linux_devmem.h" +static int +rom_sanity_check(struct pci_device *info, void *buffer) +{ + unsigned char *bios = buffer; + int offset; + unsigned short vendor, device; + + if (bios[0] != 0x55 || bios[1] != 0xAA) + return 0; + + offset = (bios[0x19] << 8) + bios[0x18]; + + if (bios[offset] != 'P' || + bios[offset+1] != 'C' || + bios[offset+2] != 'I' || + bios[offset+3] != 'R') + return 0; + + vendor = (bios[offset+5] << 8) + bios[offset+4]; + device = (bios[offset+7] << 8) + bios[offset+6]; + + return (info->vendor_id == vendor) && (info->device_id == device); +} + /** * Read a device's expansion ROM using /dev/mem. * @@ -152,5 +176,5 @@ pci_device_linux_devmem_read_rom(struct } } - return err; + return rom_sanity_check(dev, buffer); }