phy: sparx5_serdes: Fix return value check in sparx5_serdes_probe()
PATCH 1/1 phy: sparx5_serdes: Fix return value check in sparx5_serdes_probe()
From: Wei Yongjun <[email protected]>
In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.
Fixes 2ff8a1eeb5aa ("phy: Add Sparx5 ethernet serdes PHY driver")
Reported-by Hulk Robot <[email protected]>
Signed-off-by Wei Yongjun <[email protected]>
--- drivers/phy/microchip/sparx5_serdes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/microchip/sparx5_serdes.c +2 -2
@@ -2438,10 +2438,10 @@ static int sparx5_serdes_probe(struct platform_device *pdev) iores =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); iomem =devm_ioremap (priv->dev, iores->start, iores->end - iores->start +1 ); -if (IS_ERR (iomem)) { +if (!iomem) {dev_err (priv->dev,"Unable to get serdes registers: %s\n" , iores->name); -return PTR_ERR (iomem); +return -ENOMEM ; }for (idx =0 ; idx <ARRAY_SIZE (sparx5_serdes_iomap); idx++) {struct sparx5_serdes_io_resource *iomap = &sparx5_serdes_iomap[idx];
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Hello,
Quoted 18 lines · On 18/03/2021 13:56:47+0000, 'w00385741 wrote:
From: Wei Yongjun <[email protected]>
In case of error, the function
devm_ioremap()returns NULL pointer notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.Fixes 2ff8a1eeb5aa ("phy: Add Sparx5 ethernet serdes PHY driver")Reported-by Hulk Robot <[email protected]>Signed-off-by Wei Yongjun <[email protected]>--- drivers/phy/microchip/sparx5_serdes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/phy/microchip/sparx5_serdes.c +0
-0
drivers/phy/microchip/sparx5_serdes.c static int sparx5_serdes_probe(struct platform_device *pdev) · line 2445
Quoted 10 lines
drivers/phy/microchip/sparx5_serdes.c +2
-2@@ -2438,10 +2438,10 @@ static int sparx5_serdes_probe(struct platform_device *pdev) iores =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); iomem =devm_ioremap (priv->dev, iores->start, iores->end - iores->start +1 ); -if (IS_ERR (iomem)) { +if (!iomem) {dev_err (priv->dev,"Unable to get serdes registers: %s\n" , iores->name); -return PTR_ERR (iomem); +return -ENOMEM ; }
A better fix would use devm_platform_ioremap_resource and get rid of the error messages
Quoted 3 lines
drivers/phy/microchip/sparx5_serdes.c +0
-0for (idx =0 ; idx <ARRAY_SIZE (sparx5_serdes_iomap); idx++) {struct sparx5_serdes_io_resource *iomap = &sparx5_serdes_iomap[idx];
Signature · 8 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy