summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/aeroflex
diff options
context:
space:
mode:
authorPavel Skripkin <paskripkin@gmail.com>2021-06-18 17:57:31 +0300
committerDavid S. Miller <davem@davemloft.net>2021-06-19 21:45:10 +0300
commite3a5de6d81d8b2199935c7eb3f7d17a50a7075b7 (patch)
tree9e2d776ac1c45651fab21d1e238ca17320c1e142 /drivers/net/ethernet/aeroflex
parent9ed13a17e38e0537e24d9b507645002bf8d0201f (diff)
downloadlinux-e3a5de6d81d8b2199935c7eb3f7d17a50a7075b7.tar.xz
net: ethernet: aeroflex: fix UAF in greth_of_remove
static int greth_of_remove(struct platform_device *of_dev) { ... struct greth_private *greth = netdev_priv(ndev); ... unregister_netdev(ndev); free_netdev(ndev); of_iounmap(&of_dev->resource[0], greth->regs, resource_size(&of_dev->resource[0])); ... } greth is netdev private data, but it is used after free_netdev(). It can cause use-after-free when accessing greth pointer. So, fix it by moving free_netdev() after of_iounmap() call. Fixes: d4c41139df6e ("net: Add Aeroflex Gaisler 10/100/1G Ethernet MAC driver") Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/aeroflex')
-rw-r--r--drivers/net/ethernet/aeroflex/greth.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c
index d77fafbc1530..c560ad06f0be 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -1539,10 +1539,11 @@ static int greth_of_remove(struct platform_device *of_dev)
mdiobus_unregister(greth->mdio);
unregister_netdev(ndev);
- free_netdev(ndev);
of_iounmap(&of_dev->resource[0], greth->regs, resource_size(&of_dev->resource[0]));
+ free_netdev(ndev);
+
return 0;
}