summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-02-18 00:07:34 (GMT)
committerXie Xiaobo <xiaobo.xie@nxp.com>2017-09-25 07:25:33 (GMT)
commit7749ae610a243758b5c51b2d6c314cb404a6241e (patch)
tree9b9cda5b4aac6eed780b159561ece9680fd8f644 /include
parentf7c1d52082366e24d50dd6dc94329f5d3ac2610e (diff)
downloadlinux-7749ae610a243758b5c51b2d6c314cb404a6241e.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')
-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 bd22670..fd235bb 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -769,6 +769,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);
}