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

Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging

Pull dmi subsystem updates/fixes from Jean Delvare.

* 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
firmware: dmi: handle missing DMI data gracefully
firmware: dmi_scan: Fix handling of empty DMI strings
firmware: dmi_scan: Drop dmi_initialized
firmware: dmi: Optimize dmi_matches

+29 -37
+1 -1
drivers/firmware/dmi-sysfs.c
··· 652 652 int val; 653 653 654 654 if (!dmi_kobj) { 655 - pr_err("dmi-sysfs: dmi entry is absent.\n"); 655 + pr_debug("dmi-sysfs: dmi entry is absent.\n"); 656 656 error = -ENODATA; 657 657 goto err; 658 658 }
+28 -36
drivers/firmware/dmi_scan.c
··· 18 18 * of and an antecedent to, SMBIOS, which stands for System 19 19 * Management BIOS. See further: http://www.dmtf.org/standards 20 20 */ 21 - static const char dmi_empty_string[] = " "; 21 + static const char dmi_empty_string[] = ""; 22 22 23 23 static u32 dmi_ver __initdata; 24 24 static u32 dmi_len; 25 25 static u16 dmi_num; 26 26 static u8 smbios_entry_point[32]; 27 27 static int smbios_entry_point_size; 28 - 29 - /* 30 - * Catch too early calls to dmi_check_system(): 31 - */ 32 - static int dmi_initialized; 33 28 34 29 /* DMI system identification string used during boot */ 35 30 static char dmi_ids_string[128] __initdata; ··· 39 44 static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) 40 45 { 41 46 const u8 *bp = ((u8 *) dm) + dm->length; 47 + const u8 *nsp; 42 48 43 49 if (s) { 44 - s--; 45 - while (s > 0 && *bp) { 50 + while (--s > 0 && *bp) 46 51 bp += strlen(bp) + 1; 47 - s--; 48 - } 49 52 50 - if (*bp != 0) { 51 - size_t len = strlen(bp)+1; 52 - size_t cmp_len = len > 8 ? 8 : len; 53 - 54 - if (!memcmp(bp, dmi_empty_string, cmp_len)) 55 - return dmi_empty_string; 53 + /* Strings containing only spaces are considered empty */ 54 + nsp = bp; 55 + while (*nsp == ' ') 56 + nsp++; 57 + if (*nsp != '\0') 56 58 return bp; 57 - } 58 59 } 59 60 60 - return ""; 61 + return dmi_empty_string; 61 62 } 62 63 63 64 static const char * __init dmi_string(const struct dmi_header *dm, u8 s) ··· 624 633 625 634 if (!dmi_smbios3_present(buf)) { 626 635 dmi_available = 1; 627 - goto out; 636 + return; 628 637 } 629 638 } 630 639 if (efi.smbios == EFI_INVALID_TABLE_ADDR) ··· 642 651 643 652 if (!dmi_present(buf)) { 644 653 dmi_available = 1; 645 - goto out; 654 + return; 646 655 } 647 656 } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { 648 657 p = dmi_early_remap(0xF0000, 0x10000); ··· 659 668 if (!dmi_smbios3_present(buf)) { 660 669 dmi_available = 1; 661 670 dmi_early_unmap(p, 0x10000); 662 - goto out; 671 + return; 663 672 } 664 673 memcpy(buf, buf + 16, 16); 665 674 } ··· 677 686 if (!dmi_present(buf)) { 678 687 dmi_available = 1; 679 688 dmi_early_unmap(p, 0x10000); 680 - goto out; 689 + return; 681 690 } 682 691 memcpy(buf, buf + 16, 16); 683 692 } ··· 685 694 } 686 695 error: 687 696 pr_info("DMI not present or invalid.\n"); 688 - out: 689 - dmi_initialized = 1; 690 697 } 691 698 692 699 static ssize_t raw_table_read(struct file *file, struct kobject *kobj, ··· 704 715 u8 *dmi_table; 705 716 int ret = -ENOMEM; 706 717 707 - if (!dmi_available) { 708 - ret = -ENODATA; 709 - goto err; 710 - } 718 + if (!dmi_available) 719 + return 0; 711 720 712 721 /* 713 722 * Set up dmi directory at /sys/firmware/dmi. This entry should stay ··· 771 784 { 772 785 int i; 773 786 774 - WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n"); 775 - 776 787 for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) { 777 788 int s = dmi->matches[i].slot; 778 789 if (s == DMI_NONE) 779 790 break; 780 791 if (dmi_ident[s]) { 781 - if (!dmi->matches[i].exact_match && 782 - strstr(dmi_ident[s], dmi->matches[i].substr)) 783 - continue; 784 - else if (dmi->matches[i].exact_match && 785 - !strcmp(dmi_ident[s], dmi->matches[i].substr)) 786 - continue; 792 + if (dmi->matches[i].exact_match) { 793 + if (!strcmp(dmi_ident[s], 794 + dmi->matches[i].substr)) 795 + continue; 796 + } else { 797 + if (strstr(dmi_ident[s], 798 + dmi->matches[i].substr)) 799 + continue; 800 + } 787 801 } 788 802 789 803 /* No match */ ··· 814 826 * Walk the blacklist table running matching functions until someone 815 827 * returns non zero or we hit the end. Callback function is called for 816 828 * each successful match. Returns the number of matches. 829 + * 830 + * dmi_scan_machine must be called before this function is called. 817 831 */ 818 832 int dmi_check_system(const struct dmi_system_id *list) 819 833 { ··· 844 854 * 845 855 * Walk the blacklist table until the first match is found. Return the 846 856 * pointer to the matching entry or NULL if there's no match. 857 + * 858 + * dmi_scan_machine must be called before this function is called. 847 859 */ 848 860 const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list) 849 861 {