net: mvneta: fix NVMEM mac address
Subsystems (3)
PATCH 1/1 net: mvneta: fix NVMEM mac address
If nvmem loads after the ethernet driver, mac address assignments will not take effect. of_get_ethdev_address returns EPROBE_DEFER in such a case so we need to handle that to avoid eth_hw_addr_random.
--- drivers/net/ethernet/marvell/mvneta.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +2 -0
@@ -5620,6 +5620,8 @@ static int mvneta_probe(struct platform_device *pdev) } err =of_get_ethdev_address (dn, dev); +if (err == -EPROBE_DEFER ) + goto err_free_ports;if (!err) { mac_from ="device tree" ; }else {
Signature · 1 line
2.53.0
Quoted 5 lines · Rosen Penev
If nvmem loads after the ethernet driver, mac address assignments will not take effect.
of_get_ethdev_addressreturnsEPROBE_DEFERin such a case so we need to handle that to avoideth_hw_addr_random.Signed-off-by Rosen Penev <[email protected]>
Andrew
Jakub Kicinski
maintainerThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: mvneta: fix NVMEM mac address
This commit adds handling for EPROBE_DEFER from of_get_ethdev_address() to avoid falling back to a random MAC address when the NVMEM module loads after the ethernet driver.
drivers/net/ethernet/marvell/mvneta.c static int mvneta_probe(struct platform_device *pdev) · line 5624
Quoted 10 lines
drivers/net/ethernet/marvell/mvneta.c +2
-0@@ -5620,6 +5620,8 @@ static int mvneta_probe(struct platform_device *pdev) } err =of_get_ethdev_address (dn, dev); +if (err == -EPROBE_DEFER ) + goto err_free_ports;
Does this leak the per-CPU stats? Earlier in mvneta_probe(), stats are allocated:
pp->stats = netdev_alloc_pcpu_stats(struct mvneta_pcpu_stats);
if (!pp->stats) {
err = -ENOMEM;
goto err_free_ports;
}
err = of_get_ethdev_address(dn, dev);When of_get_ethdev_address() returns -EPROBE_DEFER, this code jumps to err_free_ports which only frees pp->ports but not pp->stats.
The err_free_ports label only calls free_percpu(pp->ports) and does not free pp->stats. Stats are only freed at the err_netdev label which is skipped by this error path. This causes a memory leak on every deferred probe attempt when NVMEM loads after the ethernet driver.
Quoted 3 lines
drivers/net/ethernet/marvell/mvneta.c +0
-0if (!err) { mac_from ="device tree" ; }else {
Signature · 1 line
pw-bot: cr
Jakub Kicinski
maintainerQuoted 1 line · On Thu, 5 Mar 2026 14:46:43 -0800 Rosen Penev wrote:
Subject: [PATCH net-next] net: mvneta: fix NVMEM mac address
When you repost please change the subject to
net: mvneta: support EPROBE_DEFER when reading MAC address