From b6328a07bd6b3d31b64f85864fe74f3b08c010ca Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 30 Jul 2014 00:23:09 +0200 Subject: [PATCH 1/2] ACPI / PNP: Fix acpi_pnp_match() The acpi_pnp_match() function is used for finding the ACPI device object that should be associated with the given PNP device. Unfortunately, the check used by that function is not strict enough and may cause success to be returned for a wrong ACPI device object. To fix that, use the observation that the pointer to the ACPI device object in question is already stored in the data field in struct pnp_dev, so acpi_pnp_match() can simply use that field to do its job. This problem was uncovered in 3.14 by commit 202317a573b2 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace). Fixes: 202317a573b2 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace) Reported-and-tested-by: Vinson Lee Cc: 3.14+ # 3.14+ Signed-off-by: Rafael J. Wysocki --- drivers/pnp/pnpacpi/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index b81448b2c75d..a5c6cb773e5f 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -319,8 +319,7 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp) struct pnp_dev *pnp = _pnp; /* true means it matched */ - return !acpi->physical_node_count - && compare_pnp_id(pnp->id, acpi_device_hid(acpi)); + return pnp->data == acpi; } static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev) From a5f95da9fb2a0b228b3bab19d35850af3e9a74b2 Mon Sep 17 00:00:00 2001 From: Arjun Sreedharan Date: Thu, 31 Jul 2014 14:34:49 +0530 Subject: [PATCH 2/2] ACPI / PNP: Replace faulty is_hex_digit() by isxdigit() 0 is ascii for NULL. Hex digit matching should be from '0'. Faulty version returns true for #,$,%,& etc. Signed-off-by: Arjun Sreedharan Acked-by: Randy Dunlap Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_pnp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c index 4ddb0dca56f6..996fa1959eea 100644 --- a/drivers/acpi/acpi_pnp.c +++ b/drivers/acpi/acpi_pnp.c @@ -12,6 +12,7 @@ #include #include +#include static const struct acpi_device_id acpi_pnp_device_ids[] = { /* soc_button_array */ @@ -320,11 +321,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {""}, }; -static bool is_hex_digit(char c) -{ - return (c >= 0 && c <= '9') || (c >= 'A' && c <= 'F'); -} - static bool matching_id(char *idstr, char *list_id) { int i; @@ -335,7 +331,7 @@ static bool matching_id(char *idstr, char *list_id) for (i = 3; i < 7; i++) { char c = toupper(idstr[i]); - if (!is_hex_digit(c) + if (!isxdigit(c) || (list_id[i] != 'X' && c != toupper(list_id[i]))) return false; }