Commit 46ab9b34 authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

alx: fix MAC address alignment problem

In two places, parts of MAC addresses are used as u32/u16
values. This can cause alignment problems, use put_unaligned
and get_unaligned to fix this.
Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a5b87cc9
...@@ -282,8 +282,8 @@ static bool alx_read_macaddr(struct alx_hw *hw, u8 *addr) ...@@ -282,8 +282,8 @@ static bool alx_read_macaddr(struct alx_hw *hw, u8 *addr)
mac1 = alx_read_mem32(hw, ALX_STAD1); mac1 = alx_read_mem32(hw, ALX_STAD1);
/* addr should be big-endian */ /* addr should be big-endian */
*(__be32 *)(addr + 2) = cpu_to_be32(mac0); put_unaligned(cpu_to_be32(mac0), (__be32 *)(addr + 2));
*(__be16 *)addr = cpu_to_be16(mac1); put_unaligned(cpu_to_be16(mac1), (__be16 *)addr);
return is_valid_ether_addr(addr); return is_valid_ether_addr(addr);
} }
...@@ -326,9 +326,9 @@ void alx_set_macaddr(struct alx_hw *hw, const u8 *addr) ...@@ -326,9 +326,9 @@ void alx_set_macaddr(struct alx_hw *hw, const u8 *addr)
u32 val; u32 val;
/* for example: 00-0B-6A-F6-00-DC * STAD0=6AF600DC, STAD1=000B */ /* for example: 00-0B-6A-F6-00-DC * STAD0=6AF600DC, STAD1=000B */
val = be32_to_cpu(*(__be32 *)(addr + 2)); val = be32_to_cpu(get_unaligned((__be32 *)(addr + 2)));
alx_write_mem32(hw, ALX_STAD0, val); alx_write_mem32(hw, ALX_STAD0, val);
val = be16_to_cpu(*(__be16 *)addr); val = be16_to_cpu(get_unaligned((__be16 *)addr));
alx_write_mem32(hw, ALX_STAD1, val); alx_write_mem32(hw, ALX_STAD1, val);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment