Skip to content

Commit f93f84b

Browse files
salah-trikigregkh
authored andcommitted
iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
commit 43c0f64 upstream. `devm_gpiod_get_optional()` may return non-NULL error pointer on failure. Check its return value using `IS_ERR()` and propagate the error if necessary. Fixes: df6e712 ("iio: pressure: bmp280: Explicitly mark GPIO optional") Signed-off-by: Salah Triki <salah.triki@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250818092740.545379-2-salah.triki@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8acd9a0 commit f93f84b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/iio/pressure/bmp280-core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3216,11 +3216,12 @@ int bmp280_common_probe(struct device *dev,
32163216

32173217
/* Bring chip out of reset if there is an assigned GPIO line */
32183218
gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
3219+
if (IS_ERR(gpiod))
3220+
return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get reset GPIO\n");
3221+
32193222
/* Deassert the signal */
3220-
if (gpiod) {
3221-
dev_info(dev, "release reset\n");
3222-
gpiod_set_value(gpiod, 0);
3223-
}
3223+
dev_info(dev, "release reset\n");
3224+
gpiod_set_value(gpiod, 0);
32243225

32253226
data->regmap = regmap;
32263227

0 commit comments

Comments
 (0)