Thread (14 messages) 14 messages, 2 authors, 2026-07-02

Re: [PATCH v7 6/9] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup

From: sashiko-bot@kernel.org
Date: 2026-07-02 16:01:26

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Replacing `memcpy()` with `ether_addr_copy()` introduces a strict 16-bit alignment requirement on the caller-provided address buffer, which will cause unaligned access exceptions on architectures lacking CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.
--

commit 4b3ab6cc908398547c262bcc34842d3a0a9fceab
Author: Loic Poulain [off-list ref]

net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup

This commit factors out the NVMEM EUI-48 retrieval logic into a new
of_get_nvmem_eui48() helper. The of_get_mac_address_nvmem() function is
updated to use this helper, changing how the MAC address is copied to the
caller's buffer.
quoted hunk ↗ jump to hunk
diff --git a/net/core/of_net.c b/net/core/of_net.c
index 93ea425b9248a..11c1acca15126 100644
--- a/net/core/of_net.c
+++ b/net/core/of_net.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -75,27 +73,54 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
 		return ret;
 	}
 
-	cell = of_nvmem_cell_get(np, "mac-address");
[ ... ]
-	memcpy(addr, mac, ETH_ALEN);
-	kfree(mac);
+	ret = of_get_nvmem_eui48(np, "mac-address", mac);
+	if (ret)
+		return ret;
+
+	if (!is_valid_ether_addr(mac))
+		return -EINVAL;
+
+	ether_addr_copy(addr, mac);
[Severity: High]
Does this introduce an unaligned memory access issue on architectures lacking
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS?

By replacing memcpy() with ether_addr_copy(), the caller-provided 'addr' buffer
is now strictly required to be 16-bit aligned.

Callers like of_get_ethdev_address() pass a stack-allocated, 1-byte aligned u8
array:

net/core/of_net.c:of_get_ethdev_address() {
    ...
    u8 addr[ETH_ALEN];
    int ret;

    ret = of_get_mac_address(np, addr);
    ...
}

Since of_get_mac_address() can call of_get_mac_address_nvmem(), this will cause
a hardware exception during probe when ether_addr_copy() casts the unaligned
pointer to u16* on architectures like ARMv5 or SPARC.
+	return 0;
+}
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260701-block-as-nvmem-v7-0-3fe8205ef0a8@oss.qualcomm.com?part=6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help