lkml.org 
[lkml]   [2016]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3.19.y-ckt 144/160] net: phy: mdio-mux: Check return value of mdiobus_alloc()
    Date
    3.19.8-ckt13 -stable review patch.  If anyone has any objections, please let me know.

    ---8<------------------------------------------------------------

    From: Tobias Klauser <tklauser@distanz.ch>

    commit 20b08e1a793d898f0f13040d5418ee0955f678cf upstream.

    mdiobus_alloc() might return NULL, but its return value is not
    checked in mdio_mux_init(). This could potentially lead to a NULL
    pointer dereference. Fix it by checking the return value

    Fixes: 0ca2997d1452 ("netdev/of/phy: Add MDIO bus multiplexer support.")
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Kamal Mostafa <kamal@canonical.com>
    ---
    drivers/net/phy/mdio-mux.c | 7 ++++++-
    1 file changed, 6 insertions(+), 1 deletion(-)

    diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
    index 4d4d25e..ac8a823 100644
    --- a/drivers/net/phy/mdio-mux.c
    +++ b/drivers/net/phy/mdio-mux.c
    @@ -148,9 +148,14 @@ int mdio_mux_init(struct device *dev,
    }
    cb->bus_number = v;
    cb->parent = pb;
    +
    cb->mii_bus = mdiobus_alloc();
    + if (!cb->mii_bus) {
    + ret_val = -ENOMEM;
    + of_node_put(child_bus_node);
    + break;
    + }
    cb->mii_bus->priv = cb;
    -
    cb->mii_bus->irq = cb->phy_irq;
    cb->mii_bus->name = "mdio_mux";
    snprintf(cb->mii_bus->id, MII_BUS_ID_SIZE, "%x.%x",
    --
    1.9.1

    \
     
     \ /
      Last update: 2016-01-20 03:01    [W:4.030 / U:0.928 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site