mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-09 00:46:17 +00:00
intel_bios_reader: Don't explode looking for the devid
Check that the offset where expect to find the device id is withing the BIOS image, instead of accessing whatever (if anything) happens to be there. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
This commit is contained in:
parent
b1e756451c
commit
b701bb14c6
@ -1055,11 +1055,14 @@ err:
|
||||
|
||||
|
||||
static int
|
||||
get_device_id(unsigned char *bios)
|
||||
get_device_id(unsigned char *bios, int size)
|
||||
{
|
||||
int device;
|
||||
int offset = (bios[0x19] << 8) + bios[0x18];
|
||||
|
||||
if (offset + 7 >= size)
|
||||
return -1;
|
||||
|
||||
if (bios[offset] != 'P' ||
|
||||
bios[offset+1] != 'C' ||
|
||||
bios[offset+2] != 'I' ||
|
||||
@ -1299,7 +1302,7 @@ int main(int argc, char **argv)
|
||||
printf("\n");
|
||||
|
||||
if (devid == -1)
|
||||
devid = get_device_id(VBIOS);
|
||||
devid = get_device_id(VBIOS, size);
|
||||
if (devid == -1)
|
||||
printf("Warning: could not find PCI device ID!\n");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user