From fe0653f3ea02611f63d21880e3a48137fcec975b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 4 Jan 2010 00:32:47 +0100 Subject: ignore bogus FDPT information from BIOS --- linux/src/drivers/block/ide.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'linux') diff --git a/linux/src/drivers/block/ide.c b/linux/src/drivers/block/ide.c index 5dcd0aa..e52cbed 100644 --- a/linux/src/drivers/block/ide.c +++ b/linux/src/drivers/block/ide.c @@ -2914,11 +2914,23 @@ static void probe_cmos_for_drives (ide_hwif_t *hwif) for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_drive_t *drive = &hwif->drives[unit]; if ((cmos_disks & (0xf0 >> (unit*4))) && !drive->present && !drive->nobios) { - drive->cyl = drive->bios_cyl = *(unsigned short *)BIOS; - drive->head = drive->bios_head = *(BIOS+2); - drive->sect = drive->bios_sect = *(BIOS+14); - drive->ctl = *(BIOS+8); - drive->present = 1; + unsigned short cyl = *(unsigned short *)BIOS; + unsigned char head = *(BIOS+2); + unsigned char sect = *(BIOS+14); + unsigned char ctl = *(BIOS+8); + if (cyl > 0 && head > 0 && sect > 0 && sect < 64) { + drive->cyl = drive->bios_cyl = cyl; + drive->head = drive->bios_head = head; + drive->sect = drive->bios_sect = sect; + drive->ctl = ctl; + drive->present = 1; + printk("hd%d: got CHS=%d/%d/%d CTL=%x from BIOS\n", + unit, cyl, head, sect, ctl); + + } else { + printk("hd%d: CHS=%d/%d/%d CTL=%x from BIOS ignored\n", + unit, cyl, head, sect, ctl); + } } BIOS += 16; } -- cgit v1.2.3