Skip to content

Commit 510b18c

Browse files
shimodayPaolo Abeni
authored andcommitted
rswitch: Fix renesas_eth_sw_remove() implementation
Fix functions calling order and a condition in renesas_eth_sw_remove(). Otherwise, kernel NULL pointer dereference happens from phy_stop() if a net device opens. Fixes: 3590918 ("net: ethernet: renesas: Add support for "Ethernet Switch"") Signed-off-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 50e4921 commit 510b18c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,15 +1964,17 @@ static void rswitch_deinit(struct rswitch_private *priv)
19641964
rswitch_gwca_hw_deinit(priv);
19651965
rcar_gen4_ptp_unregister(priv->ptp_priv);
19661966

1967-
for (i = 0; i < RSWITCH_NUM_PORTS; i++) {
1967+
rswitch_for_each_enabled_port(priv, i) {
19681968
struct rswitch_device *rdev = priv->rdev[i];
19691969

1970-
phy_exit(priv->rdev[i]->serdes);
1971-
rswitch_ether_port_deinit_one(rdev);
19721970
unregister_netdev(rdev->ndev);
1973-
rswitch_device_free(priv, i);
1971+
rswitch_ether_port_deinit_one(rdev);
1972+
phy_exit(priv->rdev[i]->serdes);
19741973
}
19751974

1975+
for (i = 0; i < RSWITCH_NUM_PORTS; i++)
1976+
rswitch_device_free(priv, i);
1977+
19761978
rswitch_gwca_ts_queue_free(priv);
19771979
rswitch_gwca_linkfix_free(priv);
19781980

0 commit comments

Comments
 (0)