Commit 78211543 authored by Chen Ni's avatar Chen Ni Committed by Jakub Kicinski
Browse files

net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional()...


net: ethernet: adi: adin1110: Check return value of devm_gpiod_get_optional() in adin1110_check_spi()

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: 36934cac ("net: ethernet: adi: adin1110: add reset GPIO")
Signed-off-by: default avatarChen Ni <nichen@iscas.ac.cn>
Reviewed-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20260202040228.4129097-1-nichen@iscas.ac.cn


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 3125fc17
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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.