]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dpaa2-eth: fix use-after-free in dpaa2_eth_remove
authorPavel Skripkin <paskripkin@gmail.com>
Tue, 16 Nov 2021 15:17:12 +0000 (18:17 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 Nov 2021 14:47:07 +0000 (14:47 +0000)
Access to netdev after free_netdev() will cause use-after-free bug.
Move debug log before free_netdev() call to avoid it.

Fixes: 26b115934b17 ("staging: fsl-dpaa2/eth: Move print message")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

index 714e961e7a77a28ae861a80810cd8fc320cc9733..6451c8383639fcedbe61098ad3c8e244a4fd0a69 100644 (file)
@@ -4550,10 +4550,10 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
 
        fsl_mc_portal_free(priv->mc_io);
 
-       free_netdev(net_dev);
-
        dev_dbg(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
 
+       free_netdev(net_dev);
+
        return 0;
 }