From: Ben Skeggs <[email protected]> Prevents the use of (bad) PCI ROM image on Lenovo W530.
Upstream commit: 9a334cd0de2f43b29c192548000692bad52edfc6 Signed-off-by: Ben Skeggs <[email protected]> --- drivers/gpu/drm/nouveau/nouveau_bios.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c index a0a3fe3..2bf90b0 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c @@ -196,24 +196,22 @@ static void bios_shadow_acpi(struct nvbios *bios) { struct pci_dev *pdev = bios->dev->pdev; - int cnt = 65536 / ROM_BIOS_PAGE; - int ret; + int ret, cnt, i; + u8 data[3]; if (!nouveau_acpi_rom_supported(pdev)) return; - bios->data = kmalloc(cnt * ROM_BIOS_PAGE, GFP_KERNEL); - if (!bios->data) - return; - bios->length = 0; - while (cnt--) { - ret = nouveau_acpi_get_bios_chunk(bios->data, bios->length, - ROM_BIOS_PAGE); - if (ret != ROM_BIOS_PAGE) - return; + if (nouveau_acpi_get_bios_chunk(data, 0, 3) == 3) + bios->length = data[2] * 512; - bios->length += ROM_BIOS_PAGE; + bios->data = kmalloc(bios->length, GFP_KERNEL); + for (i = 0; bios->data && i < bios->length; i += cnt) { + cnt = min((bios->length - i), (u32)4096); + ret = nouveau_acpi_get_bios_chunk(bios->data, i, cnt); + if (ret != cnt) + break; } } -- 1.7.12.3 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
