mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmi: Avoid unaligned memory access in save_mem_devices()
@ 2013-11-01 20:59 Luck, Tony
  2013-11-03 10:19 ` [tip:x86/mce] " tip-bot for Luck, Tony
  0 siblings, 1 reply; 2+ messages in thread
From: Luck, Tony @ 2013-11-01 20:59 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Chen Gong

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.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---

Ingo: belongs on top of the patches already in x86/mce branch
Found on ia64 (which grumbles about unaligned access)

 drivers/firmware/dmi_scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 59579a744d58..c7e81ff8f3ef 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -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
@@ -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++;
-- 
1.8.4.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-03 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01 20:59 [PATCH] dmi: Avoid unaligned memory access in save_mem_devices() Luck, Tony
2013-11-03 10:19 ` [tip:x86/mce] " tip-bot for Luck, Tony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®