public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi()
@ 2026-02-02  4:02 Chen Ni
  2026-02-02  6:08 ` Jijie Shao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chen Ni @ 2026-02-02  4:02 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, kuniyu,
	nicolas.dichtel, alexandru.tachici
  Cc: netdev, linux-kernel, Chen Ni

The devm_gpiod_get_optional() function may return an ERR_PTR in case of
genuine GPIO acquisition errors, not just NULL which indicates the
legitimate absence of an optional GPIO.

Add an IS_ERR() check after the call in adin1110_check_spi(). On error,
return the error code to ensure proper failure handling rather than
proceeding with invalid pointers.

Fixes: 36934cac7aaf ("net: ethernet: adi: adin1110: add reset GPIO")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/net/ethernet/adi/adin1110.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
index 30f9d271e595..71a2397edf2b 100644
--- a/drivers/net/ethernet/adi/adin1110.c
+++ b/drivers/net/ethernet/adi/adin1110.c
@@ -1089,6 +1089,9 @@ static int adin1110_check_spi(struct adin1110_priv *priv)
 
 	reset_gpio = devm_gpiod_get_optional(&priv->spidev->dev, "reset",
 					     GPIOD_OUT_LOW);
+	if (IS_ERR(reset_gpio))
+		return dev_err_probe(&priv->spidev->dev, PTR_ERR(reset_gpio),
+				     "failed to get reset gpio\n");
 	if (reset_gpio) {
 		/* MISO pin is used for internal configuration, can't have
 		 * anyone else disturbing the SDO line.
-- 
2.25.1


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

* Re: [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi()
  2026-02-02  4:02 [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi() Chen Ni
@ 2026-02-02  6:08 ` Jijie Shao
  2026-02-02 10:15 ` Nuno Sá
  2026-02-04  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jijie Shao @ 2026-02-02  6:08 UTC (permalink / raw)
  To: Chen Ni, andrew+netdev, davem, edumazet, kuba, pabeni, kuniyu,
	nicolas.dichtel, alexandru.tachici
  Cc: shaojijie, netdev, linux-kernel


on 2026/2/2 12:02, Chen Ni wrote:
> The devm_gpiod_get_optional() function may return an ERR_PTR in case of
> genuine GPIO acquisition errors, not just NULL which indicates the
> legitimate absence of an optional GPIO.
>
> Add an IS_ERR() check after the call in adin1110_check_spi(). On error,
> return the error code to ensure proper failure handling rather than
> proceeding with invalid pointers.
>
> Fixes: 36934cac7aaf ("net: ethernet: adi: adin1110: add reset GPIO")

This patch is a bugfix, so it should be sent to net, not net-next.

> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>   drivers/net/ethernet/adi/adin1110.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
> index 30f9d271e595..71a2397edf2b 100644
> --- a/drivers/net/ethernet/adi/adin1110.c
> +++ b/drivers/net/ethernet/adi/adin1110.c
> @@ -1089,6 +1089,9 @@ static int adin1110_check_spi(struct adin1110_priv *priv)
>   
>   	reset_gpio = devm_gpiod_get_optional(&priv->spidev->dev, "reset",
>   					     GPIOD_OUT_LOW);
> +	if (IS_ERR(reset_gpio))
> +		return dev_err_probe(&priv->spidev->dev, PTR_ERR(reset_gpio),
> +				     "failed to get reset gpio\n");
>   	if (reset_gpio) {
>   		/* MISO pin is used for internal configuration, can't have
>   		 * anyone else disturbing the SDO line.

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

* Re: [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi()
  2026-02-02  4:02 [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi() Chen Ni
  2026-02-02  6:08 ` Jijie Shao
@ 2026-02-02 10:15 ` Nuno Sá
  2026-02-04  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Nuno Sá @ 2026-02-02 10:15 UTC (permalink / raw)
  To: Chen Ni, andrew+netdev, davem, edumazet, kuba, pabeni, kuniyu,
	nicolas.dichtel, alexandru.tachici
  Cc: netdev, linux-kernel

On Mon, 2026-02-02 at 12:02 +0800, Chen Ni wrote:
> The devm_gpiod_get_optional() function may return an ERR_PTR in case of
> genuine GPIO acquisition errors, not just NULL which indicates the
> legitimate absence of an optional GPIO.
> 
> Add an IS_ERR() check after the call in adin1110_check_spi(). On error,
> return the error code to ensure proper failure handling rather than
> proceeding with invalid pointers.
> 
> Fixes: 36934cac7aaf ("net: ethernet: adi: adin1110: add reset GPIO")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---

For the change itself:

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

>  drivers/net/ethernet/adi/adin1110.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
> index 30f9d271e595..71a2397edf2b 100644
> --- a/drivers/net/ethernet/adi/adin1110.c
> +++ b/drivers/net/ethernet/adi/adin1110.c
> @@ -1089,6 +1089,9 @@ static int adin1110_check_spi(struct adin1110_priv *priv)
>  
>  	reset_gpio = devm_gpiod_get_optional(&priv->spidev->dev, "reset",
>  					     GPIOD_OUT_LOW);
> +	if (IS_ERR(reset_gpio))
> +		return dev_err_probe(&priv->spidev->dev, PTR_ERR(reset_gpio),
> +				     "failed to get reset gpio\n");
>  	if (reset_gpio) {
>  		/* MISO pin is used for internal configuration, can't have
>  		 * anyone else disturbing the SDO line.

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

* Re: [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi()
  2026-02-02  4:02 [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi() Chen Ni
  2026-02-02  6:08 ` Jijie Shao
  2026-02-02 10:15 ` Nuno Sá
@ 2026-02-04  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-04  3:20 UTC (permalink / raw)
  To: Chen Ni
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, kuniyu,
	nicolas.dichtel, alexandru.tachici, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  2 Feb 2026 12:02:28 +0800 you wrote:
> The devm_gpiod_get_optional() function may return an ERR_PTR in case of
> genuine GPIO acquisition errors, not just NULL which indicates the
> legitimate absence of an optional GPIO.
> 
> Add an IS_ERR() check after the call in adin1110_check_spi(). On error,
> return the error code to ensure proper failure handling rather than
> proceeding with invalid pointers.
> 
> [...]

Here is the summary with links:
  - [net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi()
    https://git.kernel.org/netdev/net/c/78211543d2e4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-02-04  3:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02  4:02 [PATCH net-next] net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi() Chen Ni
2026-02-02  6:08 ` Jijie Shao
2026-02-02 10:15 ` Nuno Sá
2026-02-04  3:20 ` patchwork-bot+netdevbpf

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