Skip to content

Commit

Permalink
net: phy: mdio-mux: Check return value of mdiobus_alloc()
Browse files Browse the repository at this point in the history
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: 0ca2997 ("netdev/of/phy: Add MDIO bus multiplexer support.")
Signed-off-by: Tobias Klauser <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tklauser authored and davem330 committed Dec 14, 2015
1 parent e5f5d74 commit 20b08e1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/net/phy/mdio-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 20b08e1

Please sign in to comment.