[PATCH] fwts:dmicheck: replace memcpy with byte copy for SMBIOS 3.0 table
wufan
wufan at codeaurora.org
Mon Nov 28 18:26:30 UTC 2016
>From 00cae446405d4d856fbd56222f835c207d18d8e8 Mon Sep 17 00:00:00 2001
From: Fan Wu <wufan at codeaurora.org>
Date: Thu, 3 Nov 2016 14:03:40 -0600
Subject: [PATCH] fwts:dmicheck: replace memcpy with byte copy for SMBIOS 3.0
table
Mapping of SMBIOS 3.0 table in AARCH64 platforms through /dev/mem
has the memory tagged as device memory, and memcpy could trigger
alignment fault if the SMBIOS table is of odd size. The fix is to
replace memcpy with byte copy.
Change-Id: I52a5be2fedcd057fdd5e510ff090e4129f128221
---
src/dmi/dmicheck/dmicheck.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
index 1934ebe..98db76b 100644
--- a/src/dmi/dmicheck/dmicheck.c
+++ b/src/dmi/dmicheck/dmicheck.c
@@ -370,8 +370,11 @@ static void* dmi_table_smbios30(fwts_framework *fw,
fwts_smbios30_entry *entry)
mem = fwts_mmap(addr, length);
if (mem != FWTS_MAP_FAILED) {
table = malloc(length);
- if (table)
- memcpy(table, mem, length);
+ if (table) {
+ size_t i = length;
+ while (i--)
+ ((uint8_t*)table)[i] = ((uint8_t*)mem)[i];
+ }
(void)fwts_munmap(mem, length);
return table;
}
--
1.8.2.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20161128/7d3e7888/attachment.html>
More information about the fwts-devel
mailing list