realtek: eth: drop device managed netdev registration

The cleanup order of the driver is quite confusing. At least
two issues exist.

- phylink_destroy() is missing
- The implicit unregister_netdev() at the end of rteth_remove() is called
  too late. The manually managed resources are removed before. This can
  lead to stale data access.

Convert to register_netdev() and bring rteth_remove() into a meaningful
order to avoid such issues when converting to page_pool.

Link: https://github.com/openwrt/openwrt/pull/23483
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
This commit is contained in:
Markus Stockhausen
2026-05-24 10:13:41 +02:00
parent 8508bcb42e
commit 934de59abe
@@ -1635,7 +1635,7 @@ static int rteth_probe(struct platform_device *pdev)
goto cleanup;
}
err = devm_register_netdev(&pdev->dev, dev);
err = register_netdev(dev);
if (err)
goto cleanup;
@@ -1656,9 +1656,10 @@ static void rteth_remove(struct platform_device *pdev)
struct rteth_ctrl *ctrl = netdev_priv(dev);
pr_info("Removing platform driver for rtl838x-eth\n");
rteth_hw_stop(ctrl);
unregister_netdev(dev);
netif_tx_stop_all_queues(dev);
if (ctrl->phylink)
phylink_destroy(ctrl->phylink);
for (int i = 0; i < RTETH_RX_RINGS; i++)
netif_napi_del(&ctrl->rx_qs[i].napi);