1 From b355cee88e3b1a193f0e9a81db810f6f83ad728b Mon Sep 17 00:00:00 2001
2 From: Zhang Rui <rui.zhang@intel.com>
3 Date: Thu, 27 Feb 2014 11:37:15 +0800
4 Subject: ACPI / resources: ignore invalid ACPI device resources
6 From: Zhang Rui <rui.zhang@intel.com>
8 commit b355cee88e3b1a193f0e9a81db810f6f83ad728b upstream.
10 ACPI table may export resource entry with 0 length.
11 But the current code interprets this kind of resource in a wrong way.
12 It will create a resource structure with
13 res->end = acpi_resource->start + acpi_resource->len - 1;
15 This patch fixes a problem on my machine that a platform device fails
16 to be created because one of its ACPI IO resource entry (start = 0,
17 end = 0, length = 0) is translated into a generic resource with
18 start = 0, end = 0xffffffff.
20 Signed-off-by: Zhang Rui <rui.zhang@intel.com>
21 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 drivers/acpi/resource.c | 10 ++++++++++
26 1 file changed, 10 insertions(+)
28 --- a/drivers/acpi/resource.c
29 +++ b/drivers/acpi/resource.c
30 @@ -77,18 +77,24 @@ bool acpi_dev_resource_memory(struct acp
32 case ACPI_RESOURCE_TYPE_MEMORY24:
33 memory24 = &ares->data.memory24;
34 + if (!memory24->address_length)
36 acpi_dev_get_memresource(res, memory24->minimum,
37 memory24->address_length,
38 memory24->write_protect);
40 case ACPI_RESOURCE_TYPE_MEMORY32:
41 memory32 = &ares->data.memory32;
42 + if (!memory32->address_length)
44 acpi_dev_get_memresource(res, memory32->minimum,
45 memory32->address_length,
46 memory32->write_protect);
48 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
49 fixed_memory32 = &ares->data.fixed_memory32;
50 + if (!fixed_memory32->address_length)
52 acpi_dev_get_memresource(res, fixed_memory32->address,
53 fixed_memory32->address_length,
54 fixed_memory32->write_protect);
55 @@ -144,12 +150,16 @@ bool acpi_dev_resource_io(struct acpi_re
57 case ACPI_RESOURCE_TYPE_IO:
59 + if (!io->address_length)
61 acpi_dev_get_ioresource(res, io->minimum,
65 case ACPI_RESOURCE_TYPE_FIXED_IO:
66 fixed_io = &ares->data.fixed_io;
67 + if (!fixed_io->address_length)
69 acpi_dev_get_ioresource(res, fixed_io->address,
70 fixed_io->address_length,