diff mbox series

[-next] net: pcs-rzn1-miic: fix return value check in miic_probe()

Message ID 20220628120850.3425568-1-yangyingliang@huawei.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series [-next] net: pcs-rzn1-miic: fix return value check in miic_probe() | expand

Commit Message

Yang Yingliang June 28, 2022, 12:08 p.m. UTC
If devm_platform_ioremap_resource() fails, it never return
NULL pointer, replace NULL test with IS_ERR().

Fixes: 7dc54d3b8d91 ("net: pcs: add Renesas MII converter driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/pcs/pcs-rzn1-miic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Clément Léger June 28, 2022, 12:05 p.m. UTC | #1
Le Tue, 28 Jun 2022 20:08:50 +0800,
Yang Yingliang <yangyingliang@huawei.com> a écrit :

> If devm_platform_ioremap_resource() fails, it never return
> NULL pointer, replace NULL test with IS_ERR().

Thanks for your patch, maybe this description would be better:

"On failure, devm_platform_ioremap_resource() returns a ERR_PTR() value
and not NULL. Fix return value checking by using IS_ERR() and
return PTR_ERR() as error value."

Clément

> 
> Fixes: 7dc54d3b8d91 ("net: pcs: add Renesas MII converter driver")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/net/pcs/pcs-rzn1-miic.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
> index 8f5e910f443d..d896961e48cc 100644
> --- a/drivers/net/pcs/pcs-rzn1-miic.c
> +++ b/drivers/net/pcs/pcs-rzn1-miic.c
> @@ -461,8 +461,8 @@ static int miic_probe(struct platform_device *pdev)
>  	spin_lock_init(&miic->lock);
>  	miic->dev = dev;
>  	miic->base = devm_platform_ioremap_resource(pdev, 0);
> -	if (!miic->base)
> -		return -EINVAL;
> +	if (IS_ERR(miic->base))
> +		return PTR_ERR(miic->base);
>  
>  	ret = devm_pm_runtime_enable(dev);
>  	if (ret < 0)
diff mbox series

Patch

diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
index 8f5e910f443d..d896961e48cc 100644
--- a/drivers/net/pcs/pcs-rzn1-miic.c
+++ b/drivers/net/pcs/pcs-rzn1-miic.c
@@ -461,8 +461,8 @@  static int miic_probe(struct platform_device *pdev)
 	spin_lock_init(&miic->lock);
 	miic->dev = dev;
 	miic->base = devm_platform_ioremap_resource(pdev, 0);
-	if (!miic->base)
-		return -EINVAL;
+	if (IS_ERR(miic->base))
+		return PTR_ERR(miic->base);
 
 	ret = devm_pm_runtime_enable(dev);
 	if (ret < 0)