Skip to content

Commit

Permalink
rswitch: Fix renesas_eth_sw_remove() implementation
Browse files Browse the repository at this point in the history
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 <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Yoshihiro Shimoda authored and Paolo Abeni committed Oct 12, 2023
1 parent 50e4921 commit 510b18c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/net/ethernet/renesas/rswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,15 +1964,17 @@ static void rswitch_deinit(struct rswitch_private *priv)
rswitch_gwca_hw_deinit(priv);
rcar_gen4_ptp_unregister(priv->ptp_priv);

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

phy_exit(priv->rdev[i]->serdes);
rswitch_ether_port_deinit_one(rdev);
unregister_netdev(rdev->ndev);
rswitch_device_free(priv, i);
rswitch_ether_port_deinit_one(rdev);
phy_exit(priv->rdev[i]->serdes);
}

for (i = 0; i < RSWITCH_NUM_PORTS; i++)
rswitch_device_free(priv, i);

rswitch_gwca_ts_queue_free(priv);
rswitch_gwca_linkfix_free(priv);

Expand Down

0 comments on commit 510b18c

Please sign in to comment.