kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] gpio: idt3243x: Fix return value check in idt_gpio_probe()
@ 2021-06-08 14:38 Wei Yongjun
  2021-06-09 11:16 ` Linus Walleij
  2021-06-11 18:58 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2021-06-08 14:38 UTC (permalink / raw)
  To: weiyongjun1, Thomas Bogendoerfer, Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, kernel-janitors, Hulk Robot

In case of error, the function devm_platform_ioremap_resource_byname()
returns ERR_PTR() and never returns NULL. The NULL test in the return
value check should be replaced with IS_ERR().

Fixes: 4195926aedca ("gpio: Add support for IDT 79RC3243x GPIO controller")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/gpio/gpio-idt3243x.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-idt3243x.c b/drivers/gpio/gpio-idt3243x.c
index e961acee1571..50003ad2e589 100644
--- a/drivers/gpio/gpio-idt3243x.c
+++ b/drivers/gpio/gpio-idt3243x.c
@@ -142,8 +142,8 @@ static int idt_gpio_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	ctrl->gpio = devm_platform_ioremap_resource_byname(pdev, "gpio");
-	if (!ctrl->gpio)
-		return -ENOMEM;
+	if (IS_ERR(ctrl->gpio))
+		return PTR_ERR(ctrl->gpio);
 
 	ctrl->gc.parent = dev;
 
@@ -160,8 +160,8 @@ static int idt_gpio_probe(struct platform_device *pdev)
 
 	if (device_property_read_bool(dev, "interrupt-controller")) {
 		ctrl->pic = devm_platform_ioremap_resource_byname(pdev, "pic");
-		if (!ctrl->pic)
-			return -ENOMEM;
+		if (IS_ERR(ctrl->pic))
+			return PTR_ERR(ctrl->pic);
 
 		parent_irq = platform_get_irq(pdev, 0);
 		if (!parent_irq)


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

* Re: [PATCH -next] gpio: idt3243x: Fix return value check in idt_gpio_probe()
  2021-06-08 14:38 [PATCH -next] gpio: idt3243x: Fix return value check in idt_gpio_probe() Wei Yongjun
@ 2021-06-09 11:16 ` Linus Walleij
  2021-06-11 18:58 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2021-06-09 11:16 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Thomas Bogendoerfer, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM, kernel-janitors, Hulk Robot

On Tue, Jun 8, 2021 at 4:28 PM Wei Yongjun <weiyongjun1@huawei.com> wrote:

> In case of error, the function devm_platform_ioremap_resource_byname()
> returns ERR_PTR() and never returns NULL. The NULL test in the return
> value check should be replaced with IS_ERR().
>
> Fixes: 4195926aedca ("gpio: Add support for IDT 79RC3243x GPIO controller")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH -next] gpio: idt3243x: Fix return value check in idt_gpio_probe()
  2021-06-08 14:38 [PATCH -next] gpio: idt3243x: Fix return value check in idt_gpio_probe() Wei Yongjun
  2021-06-09 11:16 ` Linus Walleij
@ 2021-06-11 18:58 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2021-06-11 18:58 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Thomas Bogendoerfer, Linus Walleij, linux-gpio, kernel-janitors,
	Hulk Robot

On Tue, Jun 8, 2021 at 4:28 PM Wei Yongjun <weiyongjun1@huawei.com> wrote:
>
> In case of error, the function devm_platform_ioremap_resource_byname()
> returns ERR_PTR() and never returns NULL. The NULL test in the return
> value check should be replaced with IS_ERR().
>
> Fixes: 4195926aedca ("gpio: Add support for IDT 79RC3243x GPIO controller")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/gpio/gpio-idt3243x.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-idt3243x.c b/drivers/gpio/gpio-idt3243x.c
> index e961acee1571..50003ad2e589 100644
> --- a/drivers/gpio/gpio-idt3243x.c
> +++ b/drivers/gpio/gpio-idt3243x.c
> @@ -142,8 +142,8 @@ static int idt_gpio_probe(struct platform_device *pdev)
>                 return -ENOMEM;
>
>         ctrl->gpio = devm_platform_ioremap_resource_byname(pdev, "gpio");
> -       if (!ctrl->gpio)
> -               return -ENOMEM;
> +       if (IS_ERR(ctrl->gpio))
> +               return PTR_ERR(ctrl->gpio);
>
>         ctrl->gc.parent = dev;
>
> @@ -160,8 +160,8 @@ static int idt_gpio_probe(struct platform_device *pdev)
>
>         if (device_property_read_bool(dev, "interrupt-controller")) {
>                 ctrl->pic = devm_platform_ioremap_resource_byname(pdev, "pic");
> -               if (!ctrl->pic)
> -                       return -ENOMEM;
> +               if (IS_ERR(ctrl->pic))
> +                       return PTR_ERR(ctrl->pic);
>
>                 parent_irq = platform_get_irq(pdev, 0);
>                 if (!parent_irq)
>

Applied, thanks!

Bartosz

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

end of thread, other threads:[~2021-06-11 18:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 14:38 [PATCH -next] gpio: idt3243x: Fix return value check in idt_gpio_probe() Wei Yongjun
2021-06-09 11:16 ` Linus Walleij
2021-06-11 18:58 ` Bartosz Golaszewski

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