Skip to content

Commit c75a9ad

Browse files
hkallweitdavem330
authored andcommitted
r8169: fix incorrect mac address assignment
The original changes brakes MAC address assignment on older chip versions (see bug report [0]), and it brakes random MAC assignment. is_valid_ether_addr() requires that its argument is word-aligned. Add the missing alignment to array mac_addr. [0] https://bugzilla.kernel.org/show_bug.cgi?id=215087 Fixes: 1c5d09d ("ethernet: r8169: use eth_hw_addr_set()") Reported-by: Richard Herbert <[email protected]> Tested-by: Richard Herbert <[email protected]> Signed-off-by: Heiner Kallweit <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 52911bb commit c75a9ad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,8 +5217,8 @@ static int rtl_get_ether_clk(struct rtl8169_private *tp)
52175217

52185218
static void rtl_init_mac_address(struct rtl8169_private *tp)
52195219
{
5220+
u8 mac_addr[ETH_ALEN] __aligned(2) = {};
52205221
struct net_device *dev = tp->dev;
5221-
u8 mac_addr[ETH_ALEN];
52225222
int rc;
52235223

52245224
rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr);
@@ -5233,7 +5233,8 @@ static void rtl_init_mac_address(struct rtl8169_private *tp)
52335233
if (is_valid_ether_addr(mac_addr))
52345234
goto done;
52355235

5236-
eth_hw_addr_random(dev);
5236+
eth_random_addr(mac_addr);
5237+
dev->addr_assign_type = NET_ADDR_RANDOM;
52375238
dev_warn(tp_to_dev(tp), "can't read MAC address, setting random one\n");
52385239
done:
52395240
eth_hw_addr_set(dev, mac_addr);

0 commit comments

Comments
 (0)