summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/qualcomm
diff options
context:
space:
mode:
authorPavel Skripkin <paskripkin@gmail.com>2021-07-09 16:24:18 +0200
committerDavid S. Miller <davem@davemloft.net>2021-07-09 20:01:01 +0200
commitad297cd2db8953e2202970e9504cab247b6c7cb4 (patch)
tree1ec9fb422276fe114ec28422dad5313fcb9cb93f /drivers/net/ethernet/qualcomm
parentnet: moxa: fix UAF in moxart_mac_probe (diff)
downloadlinux-ad297cd2db8953e2202970e9504cab247b6c7cb4.tar.xz
linux-ad297cd2db8953e2202970e9504cab247b6c7cb4.zip
net: qcom/emac: fix UAF in emac_remove
adpt is netdev private data and it cannot be used after free_netdev() call. Using adpt after free_netdev() can cause UAF bug. Fix it by moving free_netdev() at the end of the function. Fixes: 54e19bc74f33 ("net: qcom/emac: do not use devm on internal phy pdev") Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qualcomm')
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index 8543bf3c3484..ad655f0a4965 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -735,12 +735,13 @@ static int emac_remove(struct platform_device *pdev)
put_device(&adpt->phydev->mdio.dev);
mdiobus_unregister(adpt->mii_bus);
- free_netdev(netdev);
if (adpt->phy.digital)
iounmap(adpt->phy.digital);
iounmap(adpt->phy.base);
+ free_netdev(netdev);
+
return 0;
}