diff options
| author | Chen Ni <nichen@iscas.ac.cn> | 2026-01-30 07:18:15 +0300 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2026-03-11 03:05:38 +0300 |
| commit | 46c2891cf12c767de031a248cbb1f96d203bd3f6 (patch) | |
| tree | 73f603f378a644eed40ab0e8b434bb27be8fde0c /drivers | |
| parent | dab65dfbf9c8beb325577c35450c9d363f423f44 (diff) | |
| download | linux-46c2891cf12c767de031a248cbb1f96d203bd3f6.tar.xz | |
media: i2c: ar0521: Check return value of devm_gpiod_get_optional() in ar0521_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 <nichen@iscas.ac.cn>
Acked-by: Krzysztof HaĆasa <khalasa@piap.pl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/media/i2c/ar0521.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c index f156058500e3..ed324c2d87aa 100644 --- a/drivers/media/i2c/ar0521.c +++ b/drivers/media/i2c/ar0521.c @@ -1094,6 +1094,9 @@ static int ar0521_probe(struct i2c_client *client) /* Request optional reset pin (usually active low) and assert it */ 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"); v4l2_i2c_subdev_init(&sensor->sd, client, &ar0521_subdev_ops); |
