Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: ftgmac100: fix potential NULL pointer access in ftgmac100_phy_disconnect

After the call to phy_disconnect() netdev->phydev is reset to NULL.
So fixed_phy_unregister() would be called with a NULL pointer as argument.
Therefore cache the phy_device before this call.

Fixes: e24a6c874601 ("net: ftgmac100: Get link speed and duplex for NC-SI")
Cc: stable@vger.kernel.org
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Link: https://patch.msgid.link/2b80a77a-06db-4dd7-85dc-3a8e0de55a1d@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
e88fbc30 966c529a

+4 -3
+4 -3
drivers/net/ethernet/faraday/ftgmac100.c
··· 1750 1750 static void ftgmac100_phy_disconnect(struct net_device *netdev) 1751 1751 { 1752 1752 struct ftgmac100 *priv = netdev_priv(netdev); 1753 + struct phy_device *phydev = netdev->phydev; 1753 1754 1754 - if (!netdev->phydev) 1755 + if (!phydev) 1755 1756 return; 1756 1757 1757 - phy_disconnect(netdev->phydev); 1758 + phy_disconnect(phydev); 1758 1759 if (of_phy_is_fixed_link(priv->dev->of_node)) 1759 1760 of_phy_deregister_fixed_link(priv->dev->of_node); 1760 1761 1761 1762 if (priv->use_ncsi) 1762 - fixed_phy_unregister(netdev->phydev); 1763 + fixed_phy_unregister(phydev); 1763 1764 } 1764 1765 1765 1766 static void ftgmac100_destroy_mdio(struct net_device *netdev)