From: Chen Ni Date: Wed, 4 Feb 2026 02:48:59 +0000 (+0800) Subject: media: i2c: imx219: Check return value of devm_gpiod_get_optional() in imx219_probe() X-Git-Tag: v7.1-rc1~169^2~190 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=943b1f27a3eead21b22e2531a5432ea5910b60eb;p=thirdparty%2Fkernel%2Flinux.git media: i2c: imx219: Check return value of devm_gpiod_get_optional() in imx219_probe() 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 Reviewed-by: Dave Stevenson Reviewed-by: Jai Luthra Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index fee63bc106d9e..7da02ce5da154 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -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()