net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe()
authorZhang Changzhong <zhangchangzhong@huawei.com>
Thu, 24 Nov 2022 03:03:08 +0000 (11:03 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Nov 2022 11:00:56 +0000 (11:00 +0000)
commit46fb6512538d201d9a5b2bd7138b6751c37fdf0b
tree554a274051eec75e68e3cf23b43046163b27dedf
parent763465e6fb5b0d5a4d4e7ec48399c6f662383271
net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe()

The am65_cpsw_nuss_cleanup_ndev() function calls unregister_netdev()
even if register_netdev() fails, which triggers WARN_ON(1) in
unregister_netdevice_many(). To fix it, make sure that
unregister_netdev() is called only on registered netdev.

Compile tested only.

Fixes: 84b4aa493249 ("net: ethernet: ti: am65-cpsw: add multi port support in mac-only mode")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/am65-cpsw-nuss.c