mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
net: phy: Check against net_device being NULL
[ Upstream commit 82c76aca81 ]
In general, we don't want MAC drivers calling phy_attach_direct with the
net_device being NULL. Add checks against this in all the functions
calling it: phy_attach() and phy_connect_direct().
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
22aaae25b6
commit
846ed29eb3
@@ -729,6 +729,9 @@ int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!dev)
|
||||
return -EINVAL;
|
||||
|
||||
rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface);
|
||||
if (rc)
|
||||
return rc;
|
||||
@@ -1067,6 +1070,9 @@ struct phy_device *phy_attach(struct net_device *dev, const char *bus_id,
|
||||
struct device *d;
|
||||
int rc;
|
||||
|
||||
if (!dev)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
/* Search the list of PHY devices on the mdio bus for the
|
||||
* PHY with the requested name
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user