Skip to contentSkip to conversation

iio: amplifiers: ad8366: Add the missed check for devm_gpiod_get()

PATCH Superseded Chuhong Yuan 2 participants 2 messages May 28, 2020

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: amplifiers: ad8366: Add the missed check for devm_gpiod_get()

ad8366_probe() forgets to check the return value of devm_gpiod_get(). Add the missed check to fix it.

Fixes cee211f4e5a0 ("iio: amplifiers: ad8366: Add support for the ADA4961 DGA")

---
Changes in v2:
- Add fixes tag.

 drivers/iio/amplifiers/ad8366.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/iio/amplifiers/ad8366.c +4 -0
index 62167b87caea..b996823c8d51 100644
@@ -264,6 +264,10 @@ static int ad8366_probe(struct spi_device *spi)
 	case ID_HMC1119:
 		st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
 			GPIOD_OUT_HIGH);
+		if (IS_ERR(st->reset_gpio)) {
+			ret = PTR_ERR(st->reset_gpio);
+			goto error_disable_reg;
+		}
 		indio_dev->channels = ada4961_channels;
 		indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
 		break;
Signature · 1 line
2.26.2
#1 lore raw
Quoted 21 lines · Chuhong Yuan

[External]

ad8366_probe() forgets to check the return value of devm_gpiod_get(). Add the missed check to fix it.

Fixes cee211f4e5a0 ("iio: amplifiers: ad8366: Add support for the

ADA4961 DGA")

---
Changes in v2:
- Add fixes tag.

 drivers/iio/amplifiers/ad8366.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/iio/amplifiers/ad8366.c +0 -0
index 62167b87caea..b996823c8d51 100644

drivers/iio/amplifiers/ad8366.c static int ad8366_probe(struct spi_device *spi) · line 266

Quoted 3 lines
drivers/iio/amplifiers/ad8366.c +0 -0
@@ -264,6 +264,10 @@ static int ad8366_probe(struct spi_device *spi)
 	case ID_HMC1119:
 		st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
 			GPIOD_OUT_HIGH);

this is semi-intentional i guess;
in the sense that if there is no GPIO, nothing happens;

maybe convert this to devm_gpiod_get_optional()
otherwise, if there is no reset GPIO, this can fail the probe; and the GPIO is not optional;
rest of the code looks fine (with the devm_gpiod_get_optional() modification)

Quoted 7 lines
drivers/iio/amplifiers/ad8366.c +4 -0
+		if (IS_ERR(st->reset_gpio)) {
+			ret = PTR_ERR(st->reset_gpio);
+			goto error_disable_reg;
+		}
 		indio_dev->channels = ada4961_channels;
 		indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
 		break;