Skip to content

Commit b2b526c

Browse files
aloktiwakuba-moo
authored andcommitted
net: mdio: Check regmap pointer returned by device_node_to_regmap()
The call to device_node_to_regmap() in airoha_mdio_probe() can return an ERR_PTR() if regmap initialization fails. Currently, the driver stores the pointer without validation, which could lead to a crash if it is later dereferenced. Add an IS_ERR() check and return the corresponding error code to make the probe path more robust. Fixes: 67e3ba9 ("net: mdio: Add MDIO bus controller for Airoha AN7583") Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20251031161607.58581-1-alok.a.tiwari@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d7d2fcf commit b2b526c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/mdio/mdio-airoha.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ static int airoha_mdio_probe(struct platform_device *pdev)
219219
priv = bus->priv;
220220
priv->base_addr = addr;
221221
priv->regmap = device_node_to_regmap(dev->parent->of_node);
222+
if (IS_ERR(priv->regmap))
223+
return PTR_ERR(priv->regmap);
222224

223225
priv->clk = devm_clk_get_enabled(dev, NULL);
224226
if (IS_ERR(priv->clk))

0 commit comments

Comments
 (0)