Skip to content

Commit

Permalink
net: qcom/emac: fix UAF in emac_remove
Browse files Browse the repository at this point in the history
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: 54e19bc ("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>
  • Loading branch information
Pavel Skripkin authored and David S. Miller committed Jul 9, 2021
1 parent c78eaee commit ad297cd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/qualcomm/emac/emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ad297cd

Please sign in to comment.