Skip to content

Commit

Permalink
PNP / ACPI: proper handling of ACPI IO/Memory resource parsing failures
Browse files Browse the repository at this point in the history
Before commit b355cee (ACPI / resources: ignore invalid ACPI
device resources), if acpi_dev_resource_memory()/acpi_dev_resource_io()
returns false, it means the the resource is not a memeory/IO resource.

But after commit b355cee, those functions return false if the
given memory/IO resource entry is invalid (the length of the resource
is zero).

This breaks pnpacpi_allocated_resource(), because it now recognizes
the invalid memory/io resources as resources of unknown type.  Thus
users see confusing warning messages on machines with zero length
ACPI memory/IO resources.

Fix the problem by rearranging pnpacpi_allocated_resource() so that
it calls acpi_dev_resource_memory() for memory type and IO type
resources only, respectively.

Fixes: b355cee (ACPI / resources: ignore invalid ACPI device resources)
Signed-off-by: Zhang Rui <[email protected]>
Reported-and-tested-by: Markus Trippelsdorf <[email protected]>
Reported-and-tested-by: Julian Wollrath <[email protected]>
Reported-and-tested-by: Paul Bolle <[email protected]>
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
zhang-rui authored and rafaeljw committed Mar 11, 2014
1 parent fa389e2 commit 8993531
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/pnp/pnpacpi/rsparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
struct resource r = {0};
int i, flags;

if (acpi_dev_resource_memory(res, &r)
|| acpi_dev_resource_io(res, &r)
|| acpi_dev_resource_address_space(res, &r)
if (acpi_dev_resource_address_space(res, &r)
|| acpi_dev_resource_ext_address_space(res, &r)) {
pnp_add_resource(dev, &r);
return AE_OK;
Expand Down Expand Up @@ -217,6 +215,17 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
}

switch (res->type) {
case ACPI_RESOURCE_TYPE_MEMORY24:
case ACPI_RESOURCE_TYPE_MEMORY32:
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
if (acpi_dev_resource_memory(res, &r))
pnp_add_resource(dev, &r);
break;
case ACPI_RESOURCE_TYPE_IO:
case ACPI_RESOURCE_TYPE_FIXED_IO:
if (acpi_dev_resource_io(res, &r))
pnp_add_resource(dev, &r);
break;
case ACPI_RESOURCE_TYPE_DMA:
dma = &res->data.dma;
if (dma->channel_count > 0 && dma->channels[0] != (u8) -1)
Expand Down

0 comments on commit 8993531

Please sign in to comment.