Skip to content

Commit

Permalink
net: pasemi: fix an use-after-free in pasemi_mac_phy_init()
Browse files Browse the repository at this point in the history
The phy_dn variable is still being used in of_phy_connect() after the
of_node_put() call, which may result in use-after-free.

Fixes: 1dd2d06 ("net: Rework pasemi_mac driver to use of_mdio infrastructure")
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Wen Yang authored and David S. Miller committed Jul 8, 2019
1 parent ef86ea9 commit faf5577
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/pasemi/pasemi_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ static int pasemi_mac_phy_init(struct net_device *dev)

dn = pci_device_to_OF_node(mac->pdev);
phy_dn = of_parse_phandle(dn, "phy-handle", 0);
of_node_put(phy_dn);

mac->link = 0;
mac->speed = 0;
Expand All @@ -1051,6 +1050,7 @@ static int pasemi_mac_phy_init(struct net_device *dev)
phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0,
PHY_INTERFACE_MODE_SGMII);

of_node_put(phy_dn);
if (!phydev) {
printk(KERN_ERR "%s: Could not attach to phy\n", dev->name);
return -ENODEV;
Expand Down

0 comments on commit faf5577

Please sign in to comment.