Skip to content

Commit

Permalink
ACPI / PNP: Replace faulty is_hex_digit() by isxdigit()
Browse files Browse the repository at this point in the history
0 is ascii for NULL. Hex digit matching should be from '0'.
Faulty version returns true for #,$,%,& etc.

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Arjun Sreedharan authored and Rafael J. Wysocki committed Jul 31, 2014
1 parent feb41bb commit a5f95da
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/acpi/acpi_pnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/ctype.h>

static const struct acpi_device_id acpi_pnp_device_ids[] = {
/* soc_button_array */
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit a5f95da

Please sign in to comment.