[PATCH net] net: xilinx: ll_temac: handle of_address_to_resource() failure in MDIO setup

Pavel Zhigulin posted 1 patch 2 months, 3 weeks ago
drivers/net/ethernet/xilinx/ll_temac_mdio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH net] net: xilinx: ll_temac: handle of_address_to_resource() failure in MDIO setup
Posted by Pavel Zhigulin 2 months, 3 weeks ago
temac_mdio_setup() ignores potential errors from
of_address_to_resource() call and continues with
an uninitialized resource.

Add return value check for of_address_to_resource()
call in temac_mdio_setup().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree platforms")
Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com>
---
 drivers/net/ethernet/xilinx/ll_temac_mdio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_mdio.c b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
index 07a9fb49eda1..ab23dc233768 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_mdio.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
@@ -98,7 +98,9 @@ int temac_mdio_setup(struct temac_local *lp, struct platform_device *pdev)
 		return -ENOMEM;

 	if (np) {
-		of_address_to_resource(np, 0, &res);
+		rc = of_address_to_resource(np, 0, &res);
+		if (rc)
+			return rc;
 		snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
 			 (unsigned long long)res.start);
 	} else if (pdata) {
--
2.43.0
Re: [PATCH net] net: xilinx: ll_temac: handle of_address_to_resource() failure in MDIO setup
Posted by Andrew Lunn 2 months, 3 weeks ago
On Fri, Nov 14, 2025 at 06:55:18PM +0300, Pavel Zhigulin wrote:
> temac_mdio_setup() ignores potential errors from
> of_address_to_resource() call and continues with
> an uninitialized resource.
> 
> Add return value check for of_address_to_resource()
> call in temac_mdio_setup().
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree platforms")
> Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com>
> ---
>  drivers/net/ethernet/xilinx/ll_temac_mdio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/ll_temac_mdio.c b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
> index 07a9fb49eda1..ab23dc233768 100644
> --- a/drivers/net/ethernet/xilinx/ll_temac_mdio.c
> +++ b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
> @@ -98,7 +98,9 @@ int temac_mdio_setup(struct temac_local *lp, struct platform_device *pdev)
>  		return -ENOMEM;
> 
>  	if (np) {
> -		of_address_to_resource(np, 0, &res);
> +		rc = of_address_to_resource(np, 0, &res);
> +		if (rc)
> +			return rc;
>  		snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
>  			 (unsigned long long)res.start);

I'm not sure this is correct. But it is an odd case. Apart from
setting the name here, res is not used. Imaging a DT blob which does
not have the resource. You get a random name, but the MDIO bus works.
With your change, the probe fails. That is probably a regression.

Are there any .dts files in mainline which do not have the resource?
Then we have a clear regression, and this is then wrong.

	Andrew