Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH next] pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe()
@ 2025-03-10 10:52 Dan Carpenter
  2025-03-10 16:35 ` Nirujogi, Pratap
  2025-03-14 10:34 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-03-10 10:52 UTC (permalink / raw)
  To: Pratap Nirujogi; +Cc: Linus Walleij, linux-gpio, linux-kernel, kernel-janitors

The platform_get_resource() returns NULL on error.  It doesn't
return error pointers.  Fix the error checking to match.

Fixes: e97435ab09f3 ("pinctrl: amd: isp411: Add amdisp GPIO pinctrl")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/pinctrl/pinctrl-amdisp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-amdisp.c b/drivers/pinctrl/pinctrl-amdisp.c
index ce21ed84b929..9256ed67bb20 100644
--- a/drivers/pinctrl/pinctrl-amdisp.c
+++ b/drivers/pinctrl/pinctrl-amdisp.c
@@ -183,8 +183,8 @@ static int amdisp_pinctrl_probe(struct platform_device *pdev)
 	pdev->dev.init_name = DRV_NAME;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (IS_ERR(res))
-		return PTR_ERR(res);
+	if (!res)
+		return -EINVAL;
 
 	pctrl->gpiobase = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(pctrl->gpiobase))
-- 
2.47.2


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

* Re: [PATCH next] pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe()
  2025-03-10 10:52 [PATCH next] pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe() Dan Carpenter
@ 2025-03-10 16:35 ` Nirujogi, Pratap
  2025-03-11 15:05   ` Nirujogi, Pratap
  2025-03-14 10:34 ` Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Nirujogi, Pratap @ 2025-03-10 16:35 UTC (permalink / raw)
  To: Dan Carpenter, Pratap Nirujogi
  Cc: Linus Walleij, linux-gpio, linux-kernel, kernel-janitors,
	benjamin.chan, bin.du, gjorgji.rosikopulos, dominic.antony

Hi Dan,

Thanks for the fix. I have missed earlier that PTR_ERR() casts NULL to 
0, which kernel treats it as success and not valid in this case.

Thanks,
Pratap


On 3/10/2025 6:52 AM, Dan Carpenter wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> The platform_get_resource() returns NULL on error.  It doesn't
> return error pointers.  Fix the error checking to match.
> 
> Fixes: e97435ab09f3 ("pinctrl: amd: isp411: Add amdisp GPIO pinctrl")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   drivers/pinctrl/pinctrl-amdisp.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-amdisp.c b/drivers/pinctrl/pinctrl-amdisp.c
> index ce21ed84b929..9256ed67bb20 100644
> --- a/drivers/pinctrl/pinctrl-amdisp.c
> +++ b/drivers/pinctrl/pinctrl-amdisp.c
> @@ -183,8 +183,8 @@ static int amdisp_pinctrl_probe(struct platform_device *pdev)
>          pdev->dev.init_name = DRV_NAME;
> 
>          res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       if (IS_ERR(res))
> -               return PTR_ERR(res);
> +       if (!res)
> +               return -EINVAL;
> 
>          pctrl->gpiobase = devm_ioremap_resource(&pdev->dev, res);
>          if (IS_ERR(pctrl->gpiobase))
> --
> 2.47.2
> 


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

* Re: [PATCH next] pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe()
  2025-03-10 16:35 ` Nirujogi, Pratap
@ 2025-03-11 15:05   ` Nirujogi, Pratap
  0 siblings, 0 replies; 4+ messages in thread
From: Nirujogi, Pratap @ 2025-03-11 15:05 UTC (permalink / raw)
  To: Dan Carpenter, Pratap Nirujogi
  Cc: Linus Walleij, linux-gpio, linux-kernel, kernel-janitors,
	benjamin.chan, bin.du, gjorgji.rosikopulos, dominic.antony

Hi Dan,

Sorry I missed to add Reviewed-by flag previously.

Adding it now.

Reviewed-by: pratap.nirujogi@amd.com

Thanks,
Pratap

On 3/10/2025 12:35 PM, Nirujogi, Pratap wrote:
> Hi Dan,
> 
> Thanks for the fix. I have missed earlier that PTR_ERR() casts NULL to 
> 0, which kernel treats it as success and not valid in this case.
> 
> Thanks,
> Pratap
> 
> 
> On 3/10/2025 6:52 AM, Dan Carpenter wrote:
>> Caution: This message originated from an External Source. Use proper 
>> caution when opening attachments, clicking links, or responding.
>>
>>
>> The platform_get_resource() returns NULL on error.  It doesn't
>> return error pointers.  Fix the error checking to match.
>>
>> Fixes: e97435ab09f3 ("pinctrl: amd: isp411: Add amdisp GPIO pinctrl")
>> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>> ---
>>   drivers/pinctrl/pinctrl-amdisp.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinctrl-amdisp.c b/drivers/pinctrl/ 
>> pinctrl-amdisp.c
>> index ce21ed84b929..9256ed67bb20 100644
>> --- a/drivers/pinctrl/pinctrl-amdisp.c
>> +++ b/drivers/pinctrl/pinctrl-amdisp.c
>> @@ -183,8 +183,8 @@ static int amdisp_pinctrl_probe(struct 
>> platform_device *pdev)
>>          pdev->dev.init_name = DRV_NAME;
>>
>>          res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -       if (IS_ERR(res))
>> -               return PTR_ERR(res);
>> +       if (!res)
>> +               return -EINVAL;
>>
>>          pctrl->gpiobase = devm_ioremap_resource(&pdev->dev, res);
>>          if (IS_ERR(pctrl->gpiobase))
>> -- 
>> 2.47.2
>>
> 


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

* Re: [PATCH next] pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe()
  2025-03-10 10:52 [PATCH next] pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe() Dan Carpenter
  2025-03-10 16:35 ` Nirujogi, Pratap
@ 2025-03-14 10:34 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2025-03-14 10:34 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Pratap Nirujogi, linux-gpio, linux-kernel, kernel-janitors

On Mon, Mar 10, 2025 at 11:52 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:

> The platform_get_resource() returns NULL on error.  It doesn't
> return error pointers.  Fix the error checking to match.
>
> Fixes: e97435ab09f3 ("pinctrl: amd: isp411: Add amdisp GPIO pinctrl")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Patch applied!

Yours,
Linus Walleij

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

end of thread, other threads:[~2025-03-14 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 10:52 [PATCH next] pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe() Dan Carpenter
2025-03-10 16:35 ` Nirujogi, Pratap
2025-03-11 15:05   ` Nirujogi, Pratap
2025-03-14 10:34 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox