From jonsmirl@gmail.com Sat Jul 16 06:11:30 2005
Message-ID: <9e4733910507160609472f729c@mail.gmail.com>
Date: Sat, 16 Jul 2005 09:09:32 -0400
From: Jon Smirl <jonsmirl@gmail.com>
To: Greg KH <greg@kroah.com>, Thomas Winischhofer <thomas@winischhofer.net>
Subject: PCI: Adjust PCI rom code to handle more broken ROMs

There are ROMs reporting that their size exceeds their PCI ROM
resource window. This patch returns the minimum of the resource window
size or the size in the ROM.  An example of this breakage is the XGI
Volari Z7.

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/pci/rom.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

--- gregkh-2.6.orig/drivers/pci/rom.c	2005-06-17 12:48:29.000000000 -0700
+++ gregkh-2.6/drivers/pci/rom.c	2005-07-26 16:37:14.000000000 -0700
@@ -125,7 +125,9 @@
 		image += readw(pds + 16) * 512;
 	} while (!last_image);
 
-	*size = image - rom;
+	/* never return a size larger than the PCI resource window */
+	/* there are known ROMs that get the size wrong */
+	*size = min((size_t)(image - rom), *size);
 
 	return rom;
 }