[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1559065097-31832-4-git-send-email-ioana.ciornei@nxp.com>
Date: Tue, 28 May 2019 20:38:09 +0300
From: Ioana Ciornei <ioana.ciornei@....com>
To: linux@...linux.org.uk, f.fainelli@...il.com, andrew@...n.ch,
hkallweit1@...il.com, maxime.chevallier@...tlin.com,
olteanv@...il.com, thomas.petazzoni@...tlin.com,
davem@...emloft.net, vivien.didelot@...il.com
Cc: netdev@...r.kernel.org, Ioana Ciornei <ioana.ciornei@....com>
Subject: [PATCH v2 net-next 03/11] net: phy: Check against net_device being NULL
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@....com>
Suggested-by: Andrew Lunn <andrew@...n.ch>
Reviewed-by: Andrew Lunn <andrew@...n.ch>
---
Changes in v2:
- return directly -EINVAL instead of ERR_PTR(-EINVAL) in phy_connect_direct
drivers/net/phy/phy_device.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index da3bf3f70d63..1b540ed9b326 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -948,6 +948,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;
@@ -1307,6 +1310,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
*/
--
1.9.1
Powered by blists - more mailing lists