linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] phy: sparx5_serdes: Fix return value check in sparx5_serdes_probe()
@ 2021-03-18 13:56 'w00385741
  2021-03-18 14:11 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: 'w00385741 @ 2021-03-18 13:56 UTC (permalink / raw)
  To: weiyongjun1, Kishon Vijay Abraham I, Vinod Koul, Lars Povlsen,
	Steen Hegelund, UNGLinuxDriver, Alexandre Belloni,
	Bjarni Jonasson, Andrew Lunn
  Cc: linux-phy, linux-arm-kernel, linux-kernel, kernel-janitors, Hulk Robot

From: Wei Yongjun <weiyongjun1@huawei.com>

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 <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/phy/microchip/sparx5_serdes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/microchip/sparx5_serdes.c b/drivers/phy/microchip/sparx5_serdes.c
index 06bcf0c166cf..dd854d825000 100644
--- a/drivers/phy/microchip/sparx5_serdes.c
+++ b/drivers/phy/microchip/sparx5_serdes.c
@@ -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];


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] phy: sparx5_serdes: Fix return value check in sparx5_serdes_probe()
  2021-03-18 13:56 [PATCH -next] phy: sparx5_serdes: Fix return value check in sparx5_serdes_probe() 'w00385741
@ 2021-03-18 14:11 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2021-03-18 14:11 UTC (permalink / raw)
  To: 'w00385741
  Cc: Kishon Vijay Abraham I, Vinod Koul, Lars Povlsen, Steen Hegelund,
	UNGLinuxDriver, Bjarni Jonasson, Andrew Lunn, linux-phy,
	linux-arm-kernel, linux-kernel, kernel-janitors, Hulk Robot

Hello,

On 18/03/2021 13:56:47+0000, 'w00385741 wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> 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 <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/phy/microchip/sparx5_serdes.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/microchip/sparx5_serdes.c b/drivers/phy/microchip/sparx5_serdes.c
> index 06bcf0c166cf..dd854d825000 100644
> --- a/drivers/phy/microchip/sparx5_serdes.c
> +++ b/drivers/phy/microchip/sparx5_serdes.c
> @@ -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

>  	for (idx = 0; idx < ARRAY_SIZE(sparx5_serdes_iomap); idx++) {
>  		struct sparx5_serdes_io_resource *iomap = &sparx5_serdes_iomap[idx];
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-18 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 13:56 [PATCH -next] phy: sparx5_serdes: Fix return value check in sparx5_serdes_probe() 'w00385741
2021-03-18 14:11 ` Alexandre Belloni

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).