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