mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: i2c: vgxy61: Check return value of devm_gpiod_get_optional() in vgxy61_probe()
@ 2026-01-30  4:20 Chen Ni
  2026-01-31  6:33 ` Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Ni @ 2026-01-30  4:20 UTC (permalink / raw)
  To: sakari.ailus, benjamin.mugnier, sylvain.petinot, mchehab
  Cc: linux-media, linux-kernel, Chen Ni

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 <nichen@iscas.ac.cn>
---
 drivers/media/i2c/vgxy61.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/i2c/vgxy61.c b/drivers/media/i2c/vgxy61.c
index d64d0099e6fe..3fb2166c81ef 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) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: i2c: vgxy61: Check return value of devm_gpiod_get_optional() in vgxy61_probe()
  2026-01-30  4:20 [PATCH] media: i2c: vgxy61: Check return value of devm_gpiod_get_optional() in vgxy61_probe() Chen Ni
@ 2026-01-31  6:33 ` Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2026-01-31  6:33 UTC (permalink / raw)
  To: Chen Ni, linux-media, Benjamin Mugnier, Mauro Carvalho Chehab,
	Sakari Ailus, Sylvain Petinot
  Cc: LKML

…
> 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.

* Were any source code analysis tools involved here?

* Did anything hinder to add any tags (like “Fixes” and “Cc”) accordingly?


Regards,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-31  6:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-30  4:20 [PATCH] media: i2c: vgxy61: Check return value of devm_gpiod_get_optional() in vgxy61_probe() Chen Ni
2026-01-31  6:33 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®