Skip to content

Commit

Permalink
dmi: Avoid unaligned memory access in save_mem_devices()
Browse files Browse the repository at this point in the history
Firmware is not required to maintain alignment of SMBIOS
entries, so we should take care accessing fields within these
structures. Use "get_unaligned()" to avoid problems.

[ Found on ia64 (which grumbles about unaligned access) ]

Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: Chen Gong <gong.chen@linux.intel.com>
Link: http://lkml.kernel.org/r/27d82dbff5be1025bf18ab88498632d36c2fcf3c.1383331440.git.tony.luck@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Luck, Tony authored and Ingo Molnar committed Nov 3, 2013
1 parent d61ec84 commit 0841c04
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/firmware/dmi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/bootmem.h>
#include <linux/random.h>
#include <asm/dmi.h>
#include <asm/unaligned.h>

/*
* DMI stands for "Desktop Management Interface". It is part
Expand Down Expand Up @@ -347,7 +348,7 @@ static void __init save_mem_devices(const struct dmi_header *dm, void *v)
pr_warn(FW_BUG "Too many DIMM entries in SMBIOS table\n");
return;
}
dmi_memdev[nr].handle = dm->handle;
dmi_memdev[nr].handle = get_unaligned(&dm->handle);
dmi_memdev[nr].device = dmi_string(dm, d[0x10]);
dmi_memdev[nr].bank = dmi_string(dm, d[0x11]);
nr++;
Expand Down

0 comments on commit 0841c04

Please sign in to comment.