diff mbox series

[net] r8169: fix incorrect mac address assignment

Message ID 1100ed0d-7618-f6d6-d762-4c0c6ae6ef40@gmail.com (mailing list archive)
State Accepted
Commit c75a9ad43691de040bead75f1924928111571f9c
Delegated to: Netdev Maintainers
Headers show
Series [net] r8169: fix incorrect mac address assignment | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Heiner Kallweit Nov. 22, 2021, 9:35 p.m. UTC
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: 1c5d09d58748 ("ethernet: r8169: use eth_hw_addr_set()")
Reported-by: Richard Herbert <rherbert@sympatico.ca>
Tested-by: Richard Herbert <rherbert@sympatico.ca>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
Missing alignment and initialization of MAC address variable may affect
also other drivers where a similar change was made.
---
 drivers/net/ethernet/realtek/r8169_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski Nov. 23, 2021, 2:35 a.m. UTC | #1
On Mon, 22 Nov 2021 22:35:33 +0100 Heiner Kallweit wrote:
> 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: 1c5d09d58748 ("ethernet: r8169: use eth_hw_addr_set()")
> Reported-by: Richard Herbert <rherbert@sympatico.ca>
> Tested-by: Richard Herbert <rherbert@sympatico.ca>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Acked-by: Jakub Kicinski <kuba@kernel.org>

Thanks!
patchwork-bot+netdevbpf@kernel.org Nov. 23, 2021, 12:20 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 22 Nov 2021 22:35:33 +0100 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [net] r8169: fix incorrect mac address assignment
    https://git.kernel.org/netdev/net/c/c75a9ad43691

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index e896e5eca..e9b560051 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5226,8 +5226,8 @@  static int rtl_get_ether_clk(struct rtl8169_private *tp)
 
 static void rtl_init_mac_address(struct rtl8169_private *tp)
 {
+	u8 mac_addr[ETH_ALEN] __aligned(2) = {};
 	struct net_device *dev = tp->dev;
-	u8 mac_addr[ETH_ALEN];
 	int rc;
 
 	rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr);
@@ -5242,7 +5242,8 @@  static void rtl_init_mac_address(struct rtl8169_private *tp)
 	if (is_valid_ether_addr(mac_addr))
 		goto done;
 
-	eth_hw_addr_random(dev);
+	eth_random_addr(mac_addr);
+	dev->addr_assign_type = NET_ADDR_RANDOM;
 	dev_warn(tp_to_dev(tp), "can't read MAC address, setting random one\n");
 done:
 	eth_hw_addr_set(dev, mac_addr);