* [PATCH] net: phy: mdio-mux: Check return value of mdiobus_alloc()
@ 2015-12-14 12:51 Tobias Klauser
2015-12-14 19:30 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Tobias Klauser @ 2015-12-14 12:51 UTC (permalink / raw)
To: Florian Fainelli; +Cc: David S. Miller, netdev
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>
---
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 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",
--
2.6.3.368.gf34be46.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-14 19:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-14 12:51 [PATCH] net: phy: mdio-mux: Check return value of mdiobus_alloc() Tobias Klauser
2015-12-14 19:30 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).