drivers/net/ethernet/marvell/mvneta.c | 2 ++ 1 file changed, 2 insertions(+)
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.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/ethernet/marvell/mvneta.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index d627858d2802..2ed3397818f6 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -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 {
--
2.53.0
This 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.
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index 9ba4aef7080c..18bc13dd4e58 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -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.
> if (!err) {
> mac_from = "device tree";
> } else {
--
pw-bot: cr
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
On Thu, Mar 05, 2026 at 02:46:43PM -0800, Rosen Penev wrote:
> 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.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
© 2016 - 2026 Red Hat, Inc.