From: Chen Ni Date: Fri, 30 Jan 2026 04:20:43 +0000 (+0800) Subject: media: i2c: vgxy61: Check return value of devm_gpiod_get_optional() in vgxy61_probe() X-Git-Tag: v7.1-rc1~169^2~188 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=dab65dfbf9c8beb325577c35450c9d363f423f44;p=thirdparty%2Fkernel%2Flinux.git media: i2c: vgxy61: Check return value of devm_gpiod_get_optional() in vgxy61_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. Signed-off-by: Chen Ni Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/i2c/vgxy61.c b/drivers/media/i2c/vgxy61.c index d64d0099e6fe2..3fb2166c81ef0 100644 --- a/drivers/media/i2c/vgxy61.c +++ b/drivers/media/i2c/vgxy61.c @@ -1802,6 +1802,9 @@ static int vgxy61_probe(struct i2c_client *client) sensor->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(sensor->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(sensor->reset_gpio), + "failed to get reset gpio\n"); ret = vgxy61_get_regulators(sensor); if (ret) {