From 33dd3aa6d0f9cd240d63f53a49157ae44ebccf87 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 16:12:11 +0200
Subject: [PATCH 4/6] nss_dp_main: call unregister_netdev first in dp_remove
 and carrifer_off

In dp_remove move unregister_netdev up before calling exit and deinit
and first call netif_carrier_off to stop any traffic from happening and
prevent kernel panics for napi in the middle of transfer.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 nss_dp_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -920,6 +920,9 @@ static int nss_dp_remove(struct platform
 		dp_ops = dp_priv->data_plane_ops;
 		hal_ops = dp_priv->gmac_hal_ops;
 
+		netif_carrier_off(dp_priv->netdev);
+		unregister_netdev(dp_priv->netdev);
+
 		if (dp_priv->phydev)
 			phy_disconnect(dp_priv->phydev);
 
@@ -931,7 +934,6 @@ static int nss_dp_remove(struct platform
 #endif
 		hal_ops->exit(dp_priv->gmac_hal_ctx);
 		dp_ops->deinit(dp_priv->dpc);
-		unregister_netdev(dp_priv->netdev);
 		free_netdev(dp_priv->netdev);
 		dp_global_ctx.nss_dp[i] = NULL;
 	}
