]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: i2c: imx219: Check return value of devm_gpiod_get_optional() in imx219_probe()
authorChen Ni <nichen@iscas.ac.cn>
Wed, 4 Feb 2026 02:48:59 +0000 (10:48 +0800)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 11 Mar 2026 00:05:37 +0000 (01:05 +0100)
The devm_gpiod_get_optional() function may return an error pointer
(ERR_PTR) in case of a genuine failure during GPIO acquisition,
not just NULL which indicates the legitimate absence of an optional
GPIO.

Add an IS_ERR() check after the function call to catch such errors and
propagate them to the probe function, ensuring the driver fails to load
safely rather than proceeding with an invalid pointer.

Fixes: 1283b3b8f82b ("media: i2c: Add driver for Sony IMX219 sensor")
Cc: stable@vger.kernel.org
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/imx219.c

index fee63bc106d9e6e91f9c7ec768493e41cf4f6fb3..7da02ce5da15443e5acdfff050ef4c82500f710e 100644 (file)
@@ -1218,6 +1218,9 @@ static int imx219_probe(struct i2c_client *client)
        /* Request optional enable pin */
        imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset",
                                                     GPIOD_OUT_HIGH);
+       if (IS_ERR(imx219->reset_gpio))
+               return dev_err_probe(dev, PTR_ERR(imx219->reset_gpio),
+                                    "failed to get reset gpio\n");
 
        /*
         * The sensor must be powered for imx219_identify_module()