]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
net: enetc: fix destroyed phylink dereference during unbind
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 16 Feb 2021 10:16:28 +0000 (12:16 +0200)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 15 Mar 2021 14:09:00 +0000 (15:09 +0100)
commit8c2154ac1c00d1ee3bdaa9b526f9fe4f56d411c2
tree1f242495411e2b69af92a5407467576c3b0468e7
parent1c2b0a8f4f48a32bf20f200bbfc7c25a077c0f98
net: enetc: fix destroyed phylink dereference during unbind

[ Upstream commit 3af409ca278d4a8d50e91f9f7c4c33b175645cf3 ]

The following call path suggests that calling unregister_netdev on an
interface that is up will first bring it down.

enetc_pf_remove
-> unregister_netdev
   -> unregister_netdevice_queue
      -> unregister_netdevice_many
         -> dev_close_many
            -> __dev_close_many
               -> enetc_close
                  -> enetc_stop
                     -> phylink_stop

However, enetc first destroys the phylink instance, then calls
unregister_netdev. This is already dissimilar to the setup (and error
path teardown path) from enetc_pf_probe, but more than that, it is buggy
because it is invalid to call phylink_stop after phylink_destroy.

So let's first unregister the netdev (and let the .ndo_stop events
consume themselves), then destroy the phylink instance, then free the
netdev.

Fixes: 71b77a7a27a3 ("enetc: Migrate to PHYLINK and PCS_LYNX")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/net/ethernet/freescale/enetc/enetc_pf.c