* [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap()
@ 2025-10-31 16:15 Alok Tiwari
2025-10-31 16:32 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alok Tiwari @ 2025-10-31 16:15 UTC (permalink / raw)
To: ansuelsmth, hkallweit1, andrew, kuba, davem, edumazet, pabeni,
horms, netdev, alok.a.tiwari
Cc: alok.a.tiwarilinux
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: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
drivers/net/mdio/mdio-airoha.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/mdio/mdio-airoha.c b/drivers/net/mdio/mdio-airoha.c
index 1dc9939c8d7d..52e7475121ea 100644
--- a/drivers/net/mdio/mdio-airoha.c
+++ b/drivers/net/mdio/mdio-airoha.c
@@ -219,6 +219,8 @@ static int airoha_mdio_probe(struct platform_device *pdev)
priv = bus->priv;
priv->base_addr = addr;
priv->regmap = device_node_to_regmap(dev->parent->of_node);
+ if (IS_ERR(priv->regmap))
+ return PTR_ERR(priv->regmap);
priv->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(priv->clk))
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap()
2025-10-31 16:15 [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap() Alok Tiwari
@ 2025-10-31 16:32 ` Andrew Lunn
2025-11-04 1:10 ` patchwork-bot+netdevbpf
2025-11-04 12:01 ` Christian Marangi
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2025-10-31 16:32 UTC (permalink / raw)
To: Alok Tiwari
Cc: ansuelsmth, hkallweit1, kuba, davem, edumazet, pabeni, horms,
netdev, alok.a.tiwarilinux
On Fri, Oct 31, 2025 at 09:15:53AM -0700, Alok Tiwari wrote:
> 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: 67e3ba978361 ("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>
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap()
2025-10-31 16:15 [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap() Alok Tiwari
2025-10-31 16:32 ` Andrew Lunn
@ 2025-11-04 1:10 ` patchwork-bot+netdevbpf
2025-11-04 12:01 ` Christian Marangi
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-04 1:10 UTC (permalink / raw)
To: ALOK TIWARI
Cc: ansuelsmth, hkallweit1, andrew, kuba, davem, edumazet, pabeni,
horms, netdev, alok.a.tiwarilinux
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 31 Oct 2025 09:15:53 -0700 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [net] net: mdio: Check regmap pointer returned by device_node_to_regmap()
https://git.kernel.org/netdev/net/c/b2b526c2cf57
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap()
2025-10-31 16:15 [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap() Alok Tiwari
2025-10-31 16:32 ` Andrew Lunn
2025-11-04 1:10 ` patchwork-bot+netdevbpf
@ 2025-11-04 12:01 ` Christian Marangi
2 siblings, 0 replies; 4+ messages in thread
From: Christian Marangi @ 2025-11-04 12:01 UTC (permalink / raw)
To: Alok Tiwari
Cc: hkallweit1, andrew, kuba, davem, edumazet, pabeni, horms, netdev,
alok.a.tiwarilinux
On Fri, Oct 31, 2025 at 09:15:53AM -0700, Alok Tiwari wrote:
> 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: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Thanks for taking care. It goes against the schema but yep it's a corner
case that should be handled.
> ---
> drivers/net/mdio/mdio-airoha.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/mdio/mdio-airoha.c b/drivers/net/mdio/mdio-airoha.c
> index 1dc9939c8d7d..52e7475121ea 100644
> --- a/drivers/net/mdio/mdio-airoha.c
> +++ b/drivers/net/mdio/mdio-airoha.c
> @@ -219,6 +219,8 @@ static int airoha_mdio_probe(struct platform_device *pdev)
> priv = bus->priv;
> priv->base_addr = addr;
> priv->regmap = device_node_to_regmap(dev->parent->of_node);
> + if (IS_ERR(priv->regmap))
> + return PTR_ERR(priv->regmap);
>
> priv->clk = devm_clk_get_enabled(dev, NULL);
> if (IS_ERR(priv->clk))
> --
> 2.50.1
>
--
Ansuel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-04 12:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-31 16:15 [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap() Alok Tiwari
2025-10-31 16:32 ` Andrew Lunn
2025-11-04 1:10 ` patchwork-bot+netdevbpf
2025-11-04 12:01 ` Christian Marangi
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).