Skip to contentSkip to conversation

net: mvneta: fix NVMEM mac address

PATCH In review Rosen Penev 3 participants 4 messages Mar 5 – Mar 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index d627858d2802..2ed3397818f6 100644
@@ -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
maintainer
#2 lore raw
In reply to Rosen Penev

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.

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
index 9ba4aef7080c..18bc13dd4e58 100644
@@ -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 -0
 	if (!err) {
 		mac_from = "device tree";
 	} else {
Signature · 1 line
pw-bot: cr
maintainer
#3 lore raw
In reply to Rosen Penev
Quoted 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