drm/nouveau/bios: fetch full 4KiB block to determine ACPI ROM image size
authorBen Skeggs <bskeggs@redhat.com>
Mon, 22 Oct 2012 00:08:19 +0000 (10:08 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 22 Oct 2012 03:39:38 +0000 (13:39 +1000)
Buggy firmware leads to bad things happening otherwise..

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/subdev/bios/base.c

index 3a84ad4f171aa31e5d3f2b9fb8c9b130da0593ee..70ca7d5a1aa1aaa4e4302ab599ed5398d4f666eb 100644 (file)
@@ -192,7 +192,6 @@ nouveau_bios_shadow_acpi(struct nouveau_bios *bios)
 {
        struct pci_dev *pdev = nv_device(bios)->pdev;
        int ret, cnt, i;
-       u8  data[3];
 
        if (!nouveau_acpi_rom_supported(pdev)) {
                bios->data = NULL;
@@ -200,8 +199,13 @@ nouveau_bios_shadow_acpi(struct nouveau_bios *bios)
        }
 
        bios->size = 0;
-       if (nouveau_acpi_get_bios_chunk(data, 0, 3) == 3)
-               bios->size = data[2] * 512;
+       bios->data = kmalloc(4096, GFP_KERNEL);
+       if (bios->data) {
+               if (nouveau_acpi_get_bios_chunk(bios->data, 0, 4096) == 4096)
+                       bios->size = bios->data[2] * 512;
+               kfree(bios->data);
+       }
+
        if (!bios->size)
                return;