lkml.org 
[lkml]   [2019]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 022/223] net: phy: Check against net_device being NULL
    Date
    [ Upstream commit 82c76aca81187b3d28a6fb3062f6916450ce955e ]

    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>
    ---
    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 5048a6df6a8e..5c2c72b1ef8b 100644
    --- a/drivers/net/phy/phy_device.c
    +++ b/drivers/net/phy/phy_device.c
    @@ -673,6 +673,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;
    @@ -965,6 +968,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
    */
    --
    2.20.1


    \
     
     \ /
      Last update: 2019-08-02 12:09    [W:4.027 / U:0.280 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site