Skip to content

Commit

Permalink
dmi: prevent linked list corruption
Browse files Browse the repository at this point in the history
Adding the same item to a given linked list more than once is guaranteed
to break and corrupt the list.  This is however what we do in dmi_scan
since commit 79da472 ("x86: fix DMI out
of memory problems").

Given that there is absolutely no interest in saving empty OEM strings
anyway, I propose the simple and efficient fix below: we discard the empty
OEM strings altogether.

Signed-off-by: Jean Delvare <[email protected]>
Acked-by: Parag Warudkar <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Matt Domsch <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jean Delvare authored and Linus Torvalds committed Feb 24, 2008
1 parent 79306a3 commit 43fe105
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions drivers/firmware/dmi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ static void __init dmi_save_devices(const struct dmi_header *dm)
}
}

static struct dmi_device empty_oem_string_dev = {
.name = dmi_empty_string,
};

static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
{
int i, count = *(u8 *)(dm + 1);
Expand All @@ -229,10 +225,8 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
for (i = 1; i <= count; i++) {
char *devname = dmi_string(dm, i);

if (!strcmp(devname, dmi_empty_string)) {
list_add(&empty_oem_string_dev.list, &dmi_devices);
if (devname == dmi_empty_string)
continue;
}

dev = dmi_alloc(sizeof(*dev));
if (!dev) {
Expand Down

0 comments on commit 43fe105

Please sign in to comment.