]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
authorSalah Triki <salah.triki@gmail.com>
Mon, 18 Aug 2025 09:27:30 +0000 (10:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:39 +0000 (16:34 +0200)
commit 43c0f6456f801181a80b73d95def0e0fd134e1cc 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: df6e71256c84 ("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>
drivers/iio/pressure/bmp280-core.c

index f37f20776c89173b0b2a8e28be0ef9aa30ceea53..0f23ece440004c3b6de8d99632fef575e30bcb3e 100644 (file)
@@ -3216,11 +3216,12 @@ int bmp280_common_probe(struct device *dev,
 
        /* Bring chip out of reset if there is an assigned GPIO line */
        gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+       if (IS_ERR(gpiod))
+               return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get reset GPIO\n");
+
        /* Deassert the signal */
-       if (gpiod) {
-               dev_info(dev, "release reset\n");
-               gpiod_set_value(gpiod, 0);
-       }
+       dev_info(dev, "release reset\n");
+       gpiod_set_value(gpiod, 0);
 
        data->regmap = regmap;