mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
backlight: hx8357: Fix potential NULL pointer dereference
The "im" pins are optional. Add missing check in the hx8357_probe().
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/642e1230-3358-4006-a17f-3f297897ae74@moroto.mountain
Fixes: 7d84a63a39
("backlight: hx8357: Convert to agnostic GPIO API")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240114143921.550736-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
7774f3d1dd
commit
b1ba8bcb2d
1 changed files with 6 additions and 4 deletions
|
@ -609,11 +609,13 @@ static int hx8357_probe(struct spi_device *spi)
|
|||
lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(lcd->im_pins))
|
||||
return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to request im GPIOs\n");
|
||||
if (lcd->im_pins) {
|
||||
if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS)
|
||||
return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n");
|
||||
|
||||
for (i = 0; i < HX8357_NUM_IM_PINS; i++)
|
||||
gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins");
|
||||
}
|
||||
|
||||
lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd,
|
||||
&hx8357_ops);
|
||||
|
|
Loading…
Add table
Reference in a new issue