net: dsa: bcm_sf2: Fix driver removal
authorFlorian Fainelli <f.fainelli@gmail.com>
Sun, 3 Nov 2019 03:17:39 +0000 (20:17 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Nov 2019 01:54:59 +0000 (17:54 -0800)
With the DSA core doing the call to dsa_port_disable() we do not need to
do that within the driver itself. This could cause an use after free
since past dsa_unregister_switch() we should not be accessing any
dsa_switch internal structures.

Fixes: 0394a63acfe2 ("net: dsa: enable and disable all ports")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/bcm_sf2.c

index d44651ad520c10d7e21d5f7793baab248e389b7c..69fc13046ac718aa763d2719d7d964df3fe64893 100644 (file)
@@ -1215,10 +1215,10 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
        struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
 
        priv->wol_ports_mask = 0;
+       /* Disable interrupts */
+       bcm_sf2_intr_disable(priv);
        dsa_unregister_switch(priv->dev->ds);
        bcm_sf2_cfp_exit(priv->dev->ds);
-       /* Disable all ports and interrupts */
-       bcm_sf2_sw_suspend(priv->dev->ds);
        bcm_sf2_mdio_unregister(priv);
 
        return 0;