Re: [PATCH 2/3] gpio: pxa: Fix return value of pxa_gpio_probe()

From: Robert Jarzmik
Date: Fri May 22 2020 - 15:07:54 EST


Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> writes:

> When call function devm_platform_ioremap_resource(), we should use IS_ERR()
> to check the return value and return PTR_ERR() if failed.
>
> Fixes: 542c25b7a209 ("drivers: gpio: pxa: use devm_platform_ioremap_resource()")
> Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
> ---
> drivers/gpio/gpio-pxa.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> index 1361270..0cb6600 100644
> --- a/drivers/gpio/gpio-pxa.c
> +++ b/drivers/gpio/gpio-pxa.c
> @@ -660,8 +660,8 @@ static int pxa_gpio_probe(struct platform_device *pdev)
> pchip->irq1 = irq1;
>
> gpio_reg_base = devm_platform_ioremap_resource(pdev, 0);
> - if (!gpio_reg_base)
> - return -EINVAL;
> + if (IS_ERR(gpio_reg_base))
> + return PTR_ERR(gpio_reg_base);
As far as I know, devm_platform_ioremap_resource() could return NULL which is
not handled by this test (unless __devm_ioremap() semantics changed since I had
a look).

Therefore, this patch is incorrect, or rather incomplete.

Cheers.

--
Robert