net: phy: don't crash in phy_read/_write_mmd without a PHY driver
authorAlex Marginean <alexandru.marginean@nxp.com>
Thu, 16 Jan 2020 17:46:28 +0000 (19:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Jan 2020 09:08:20 +0000 (10:08 +0100)
commit3e41d04e2b7373490977d7145fb12109f23cde9c
treeef84fc515320be248eca978320a1052726605226
parent6cbdcf25bdec944f85bb2ef7ebe959bdb7dc59b8
net: phy: don't crash in phy_read/_write_mmd without a PHY driver

The APIs can be used by Ethernet drivers without actually loading a PHY
driver. This may become more widespread in the future with 802.3z
compatible MAC PCS devices being locally driven by the MAC driver when
configuring for a PHY mode with in-band negotiation.

Check that drv is not NULL before reading from it.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy-core.c