ACPI / bus: Do not traverse through non-existed device table
PATCH v2 2/6 ACPI / bus: Do not traverse through non-existed device table
Quoted 2 lines · Andy Shevchenko
When
__acpi_match_device()is called it would be possible to have ACPI ID table a MULL pointer. To avoid potential dereference,
NULL
Quoted 28 lines
check for this before traverse.
While here, remove redundant 'else'.
Fixes 80212a162329 ("ACPI / bus: Introduce acpi_get_match_data() function")Cc Sinan Kaya <[email protected]>Cc Sakari Ailus <[email protected]>Cc Vinod Koul <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>---
v2: new patchdrivers/acpi/bus.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/acpi/bus.c +0
-5@@ -745,11 +745,13 @@ static const struct acpi_device_id *__acpi_match_device(list_for_each_entry (hwid, &device->pnp.ids, list) {/* First, check the ACPI/PNP IDs provided by the caller. */ -for (id = ids; id->id[0 ] || id->cls; id++) { -if (id->id[0 ] && !strcmp ((char *) id->id, hwid->id)) -return id; -else if (id->cls &&__acpi_match_device_cls (id, hwid)) -return id;
drivers/acpi/bus.c static const struct acpi_device_id *__acpi_match_device( · line 757
Quoted 10 lines
drivers/acpi/bus.c +7
-0+if (ids) { +for (id = ids; id->id[0 ] || id->cls; id++) { +if (id->id[0 ] && !strcmp ((char *)id->id, hwid->id)) +return id; +if (id->cls &&__acpi_match_device_cls (id, hwid)) +return id; + } }/*
Why not bail out here immediately if ids is null?
__acpi_match_device()
{
/*
* If the device is not present, it is unnecessary to load device
* driver for it.
*/
if (!device || !device->status.present)
return NULL;
}