Commit ea71f98d authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Dave Airlie

nouveau: Fix crash when pci_ram_rom() returns a size of 0

From b15b244d6e6e20964bd4b85306722cb60c3c0809 Mon Sep 17 00:00:00 2001
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: Mon, 2 Apr 2012 13:28:18 +1000
Subject:

Under some circumstances, pci_map_rom() can return a valid mapping
but a size of 0 (if it cannot find an image in the header).

This causes nouveau to try to kmalloc() a 0 sized pointer and
dereference it, which crashes.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 40c61046
...@@ -177,14 +177,15 @@ bios_shadow_pci(struct nvbios *bios) ...@@ -177,14 +177,15 @@ bios_shadow_pci(struct nvbios *bios)
if (!pci_enable_rom(pdev)) { if (!pci_enable_rom(pdev)) {
void __iomem *rom = pci_map_rom(pdev, &length); void __iomem *rom = pci_map_rom(pdev, &length);
if (rom) { if (rom && length) {
bios->data = kmalloc(length, GFP_KERNEL); bios->data = kmalloc(length, GFP_KERNEL);
if (bios->data) { if (bios->data) {
memcpy_fromio(bios->data, rom, length); memcpy_fromio(bios->data, rom, length);
bios->length = length; bios->length = length;
} }
pci_unmap_rom(pdev, rom);
} }
if (rom)
pci_unmap_rom(pdev, rom);
pci_disable_rom(pdev); pci_disable_rom(pdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment