summaryrefslogtreecommitdiff
path: root/include/linux/phy.h
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-02-18 03:07:34 +0300
committerDavid S. Miller <davem@davemloft.net>2017-02-20 18:15:11 +0300
commit25149ef9d25cafc4f4fe9f4461f18f876f397417 (patch)
treeacc10c699ffcb5ceed825af9f051971f94387b09 /include/linux/phy.h
parent7b9a88a390dacb37b051a7b09b9a08f546edf5eb (diff)
downloadlinux-25149ef9d25cafc4f4fe9f4461f18f876f397417.tar.xz
net: phy: Check phydev->drv
There are number of function calls, originating from user-space, typically through the Ethernet driver that can make us crash by dereferencing phydev->drv which will be NULL once we unbind the driver from the PHY. There are still functional issues that prevent an unbind then rebind to work, but these will be addressed separately. Suggested-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r--include/linux/phy.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h
index d9bdf53e0514..772476028a65 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -807,6 +807,9 @@ int phy_stop_interrupts(struct phy_device *phydev);
static inline int phy_read_status(struct phy_device *phydev)
{
+ if (!phydev->drv)
+ return -EIO;
+
return phydev->drv->read_status(phydev);
}