From 055f763ca8c0eb69724cf5c1e5cb9511dce724f9 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 16 Jul 2010 16:25:53 -0700 Subject: [PATCH] diskio: check early for an impossible LBA value for CHS requests Make sure we don't end up trying to do a CHS request for a truly absurd value, that could possibly be misconverted. Signed-off-by: H. Peter Anvin --- core/fs/diskio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/fs/diskio.c b/core/fs/diskio.c index 822314c..cf9bf49 100644 --- a/core/fs/diskio.c +++ b/core/fs/diskio.c @@ -25,6 +25,9 @@ static int chs_rdwr_sectors(struct disk *disk, void *buf, int retry; uint32_t maxtransfer = disk->maxtransfer; + if (lba + disk->part_start >= 1024*256*63) + return 0; /* Impossible CHS request */ + memset(&ireg, 0, sizeof ireg); ireg.eax.b[1] = 0x02 + is_write; -- 2.7.4