* [PATCH] media: i2c: mt9p031: Check return value of devm_gpiod_get_optional() in mt9p031_probe()
@ 2026-02-02 2:43 Chen Ni
0 siblings, 0 replies; only message in thread
From: Chen Ni @ 2026-02-02 2:43 UTC (permalink / raw)
To: sakari.ailus, laurent.pinchart, 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/mt9p031.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 1500ee4db47e..ea5d43d925ff 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1183,6 +1183,10 @@ static int mt9p031_probe(struct i2c_client *client)
mt9p031->reset = devm_gpiod_get_optional(&client->dev, "reset",
GPIOD_OUT_HIGH);
+ if (IS_ERR(mt9p031->reset)) {
+ ret = PTR_ERR(mt9p031->reset);
+ goto done;
+ }
ret = mt9p031_clk_setup(mt9p031);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-02-02 2:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 2:43 [PATCH] media: i2c: mt9p031: Check return value of devm_gpiod_get_optional() in mt9p031_probe() Chen Ni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox