]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fdt: remove unaligned access in fdt_fixup_ethernet()
authorStephen Warren <swarren@wwwdotorg.org>
Mon, 27 May 2013 18:01:19 +0000 (18:01 +0000)
committerTom Rini <trini@ti.com>
Fri, 7 Jun 2013 18:17:01 +0000 (14:17 -0400)
Some ARM compilers may emit code that makes unaligned accesses when
faced with constructs such as:

char mac[16] = "ethaddr";

Replace this with a strcpy() call instead to avoid this. strcpy() is
used here, rather than replacing all usage of the mac variable with the
string itself, since the loop itself sprintf()s to the variable each
iteration, so strcpy() is doing basically the same thing.

Reported-by: Florian Meier
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
common/fdt_support.c

index 416100e394dc92d3c61f143aa807681b1a5c84ce..9a6f6b7d8b16c822496c53a62df26d3850081b29 100644 (file)
@@ -458,7 +458,7 @@ void fdt_fixup_ethernet(void *fdt)
 {
        int node, i, j;
        char enet[16], *tmp, *end;
-       char mac[16] = "ethaddr";
+       char mac[16];
        const char *path;
        unsigned char mac_addr[6];
 
@@ -467,6 +467,7 @@ void fdt_fixup_ethernet(void *fdt)
                return;
 
        i = 0;
+       strcpy(mac, "ethaddr");
        while ((tmp = getenv(mac)) != NULL) {
                sprintf(enet, "ethernet%d", i);
                path = fdt_getprop(fdt, node, enet, NULL);