diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2015-12-14 13:51:51 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-12-14 14:27:40 -0500 |
commit | 20b08e1a793d898f0f13040d5418ee0955f678cf (patch) | |
tree | 3e35b883fd2b52e4c93ca8b6e12e1bb88f4a646a /drivers/net/phy/mdio-mux.c | |
parent | e5f5d74747afa799bff109644be04b00af36043e (diff) | |
download | linux-20b08e1a793d898f0f13040d5418ee0955f678cf.tar.bz2 |
net: phy: mdio-mux: Check return value of mdiobus_alloc()
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>
Diffstat (limited to 'drivers/net/phy/mdio-mux.c')
-rw-r--r-- | drivers/net/phy/mdio-mux.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c index 908e8d486342..7f8e7662e28c 100644 --- a/drivers/net/phy/mdio-mux.c +++ b/drivers/net/phy/mdio-mux.c @@ -149,9 +149,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", |