aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firmware/dmi_scan.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 5e596a7e3601..0b24a1141009 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -8,6 +8,8 @@
8#include <linux/slab.h> 8#include <linux/slab.h>
9#include <asm/dmi.h> 9#include <asm/dmi.h>
10 10
11static char dmi_empty_string[] = " ";
12
11static char * __init dmi_string(const struct dmi_header *dm, u8 s) 13static char * __init dmi_string(const struct dmi_header *dm, u8 s)
12{ 14{
13 const u8 *bp = ((u8 *) dm) + dm->length; 15 const u8 *bp = ((u8 *) dm) + dm->length;
@@ -21,11 +23,16 @@ static char * __init dmi_string(const struct dmi_header *dm, u8 s)
21 } 23 }
22 24
23 if (*bp != 0) { 25 if (*bp != 0) {
24 str = dmi_alloc(strlen(bp) + 1); 26 size_t len = strlen(bp)+1;
27 size_t cmp_len = len > 8 ? 8 : len;
28
29 if (!memcmp(bp, dmi_empty_string, cmp_len))
30 return dmi_empty_string;
31 str = dmi_alloc(len);
25 if (str != NULL) 32 if (str != NULL)
26 strcpy(str, bp); 33 strcpy(str, bp);
27 else 34 else
28 printk(KERN_ERR "dmi_string: out of memory.\n"); 35 printk(KERN_ERR "dmi_string: cannot allocate %Zu bytes.\n", len);
29 } 36 }
30 } 37 }
31 38
@@ -175,12 +182,23 @@ static void __init dmi_save_devices(const struct dmi_header *dm)
175 } 182 }
176} 183}
177 184
185static struct dmi_device empty_oem_string_dev = {
186 .name = dmi_empty_string,
187};
188
178static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) 189static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
179{ 190{
180 int i, count = *(u8 *)(dm + 1); 191 int i, count = *(u8 *)(dm + 1);
181 struct dmi_device *dev; 192 struct dmi_device *dev;
182 193
183 for (i = 1; i <= count; i++) { 194 for (i = 1; i <= count; i++) {
195 char *devname = dmi_string(dm, i);
196
197 if (!strcmp(devname, dmi_empty_string)) {
198 list_add(&empty_oem_string_dev.list, &dmi_devices);
199 continue;
200 }
201
184 dev = dmi_alloc(sizeof(*dev)); 202 dev = dmi_alloc(sizeof(*dev));
185 if (!dev) { 203 if (!dev) {
186 printk(KERN_ERR 204 printk(KERN_ERR
@@ -189,7 +207,7 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
189 } 207 }
190 208
191 dev->type = DMI_DEV_TYPE_OEM_STRING; 209 dev->type = DMI_DEV_TYPE_OEM_STRING;
192 dev->name = dmi_string(dm, i); 210 dev->name = devname;
193 dev->device_data = NULL; 211 dev->device_data = NULL;
194 212
195 list_add(&dev->list, &dmi_devices); 213 list_add(&dev->list, &dmi_devices);