Skip to content

Commit a2f8371

Browse files
zhang-ruigregkh
authored andcommitted
ACPI / resources: ignore invalid ACPI device resources
commit b355cee upstream. ACPI table may export resource entry with 0 length. But the current code interprets this kind of resource in a wrong way. It will create a resource structure with res->end = acpi_resource->start + acpi_resource->len - 1; This patch fixes a problem on my machine that a platform device fails to be created because one of its ACPI IO resource entry (start = 0, end = 0, length = 0) is translated into a generic resource with start = 0, end = 0xffffffff. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9a59929 commit a2f8371

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎drivers/acpi/resource.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,24 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)
7777
switch (ares->type) {
7878
case ACPI_RESOURCE_TYPE_MEMORY24:
7979
memory24 = &ares->data.memory24;
80+
if (!memory24->address_length)
81+
return false;
8082
acpi_dev_get_memresource(res, memory24->minimum,
8183
memory24->address_length,
8284
memory24->write_protect);
8385
break;
8486
case ACPI_RESOURCE_TYPE_MEMORY32:
8587
memory32 = &ares->data.memory32;
88+
if (!memory32->address_length)
89+
return false;
8690
acpi_dev_get_memresource(res, memory32->minimum,
8791
memory32->address_length,
8892
memory32->write_protect);
8993
break;
9094
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
9195
fixed_memory32 = &ares->data.fixed_memory32;
96+
if (!fixed_memory32->address_length)
97+
return false;
9298
acpi_dev_get_memresource(res, fixed_memory32->address,
9399
fixed_memory32->address_length,
94100
fixed_memory32->write_protect);
@@ -144,12 +150,16 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)
144150
switch (ares->type) {
145151
case ACPI_RESOURCE_TYPE_IO:
146152
io = &ares->data.io;
153+
if (!io->address_length)
154+
return false;
147155
acpi_dev_get_ioresource(res, io->minimum,
148156
io->address_length,
149157
io->io_decode);
150158
break;
151159
case ACPI_RESOURCE_TYPE_FIXED_IO:
152160
fixed_io = &ares->data.fixed_io;
161+
if (!fixed_io->address_length)
162+
return false;
153163
acpi_dev_get_ioresource(res, fixed_io->address,
154164
fixed_io->address_length,
155165
ACPI_DECODE_10);

0 commit comments

Comments
 (0)