Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/platform/x86/acerhdf.c: check BIOS information whether it begins with string of table

BIOS information is now checked whether it begins with the strings stored
in the BIOS table. Previous method did a strcmp, what lead to problems if
BIOS information has appended whitespaces.

Signed-off-by: Peter Feuerer <peter@piie.net>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Andreas Mohr <andi@lisas.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by

Peter Feuerer and committed by
Len Brown
dcbfb815 94219d79

+28 -18
+28 -18
drivers/platform/x86/acerhdf.c
··· 52 52 */ 53 53 #undef START_IN_KERNEL_MODE 54 54 55 - #define DRV_VER "0.5.21" 55 + #define DRV_VER "0.5.22" 56 56 57 57 /* 58 58 * According to the Atom N270 datasheet, ··· 165 165 /* Gateway */ 166 166 {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x21, 0x00} }, 167 167 {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x20, 0x00} }, 168 - {"Gateway ", "LT31 ", "v1.3103 ", 0x55, 0x58, 169 - {0x10, 0x0f, 0x00} }, 170 - {"Gateway ", "LT31 ", "v1.3201 ", 0x55, 0x58, 171 - {0x10, 0x0f, 0x00} }, 172 - {"Gateway ", "LT31 ", "v1.3302 ", 0x55, 0x58, 173 - {0x10, 0x0f, 0x00} }, 168 + {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x10, 0x0f, 0x00} }, 169 + {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x10, 0x0f, 0x00} }, 170 + {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x10, 0x0f, 0x00} }, 174 171 /* Packard Bell */ 175 172 {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x21, 0x00} }, 176 173 {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x20, 0x00} }, ··· 492 495 .remove = acerhdf_remove, 493 496 }; 494 497 498 + /* checks if str begins with start */ 499 + static int str_starts_with(const char *str, const char *start) 500 + { 501 + unsigned long str_len = 0, start_len = 0; 502 + 503 + str_len = strlen(str); 504 + start_len = strlen(start); 505 + 506 + if (str_len >= start_len && 507 + !strncmp(str, start, start_len)) 508 + return 1; 509 + 510 + return 0; 511 + } 495 512 496 513 /* check hardware */ 497 514 static int acerhdf_check_hardware(void) 498 515 { 499 516 char const *vendor, *version, *product; 500 - int i; 501 - unsigned long prod_len = 0; 517 + const struct bios_settings_t *bt = NULL; 502 518 503 519 /* get BIOS data */ 504 520 vendor = dmi_get_system_info(DMI_SYS_VENDOR); ··· 533 523 kernelmode = 0; 534 524 } 535 525 536 - prod_len = strlen(product); 537 - 538 526 if (verbose) 539 527 pr_info("BIOS info: %s %s, product: %s\n", 540 528 vendor, version, product); 541 529 542 530 /* search BIOS version and vendor in BIOS settings table */ 543 - for (i = 0; bios_tbl[i].version[0]; i++) { 544 - if (strlen(bios_tbl[i].product) >= prod_len && 545 - !strncmp(bios_tbl[i].product, product, 546 - strlen(bios_tbl[i].product)) && 547 - !strcmp(bios_tbl[i].vendor, vendor) && 548 - !strcmp(bios_tbl[i].version, version)) { 549 - bios_cfg = &bios_tbl[i]; 531 + for (bt = bios_tbl; bt->vendor[0]; bt++) { 532 + /* 533 + * check if actual hardware BIOS vendor, product and version 534 + * IDs start with the strings of BIOS table entry 535 + */ 536 + if (str_starts_with(vendor, bt->vendor) && 537 + str_starts_with(product, bt->product) && 538 + str_starts_with(version, bt->version)) { 539 + bios_cfg = bt; 550 540 break; 551 541 } 552 542 }