backlight: hx8357: Fix potential NULL pointer dereference
Subsystems (2)
PATCH 1/1 backlight: hx8357: Fix potential NULL pointer dereference
The "im" pins are optional. Add missing check in the hx8357_probe().
Reported-by Dan Carpenter <[email protected]>
Fixes 7d84a63a39b7 ("backlight: hx8357: Convert to agnostic GPIO API")
Signed-off-by Andy Shevchenko <[email protected]>
--- drivers/video/backlight/hx8357.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/video/backlight/hx8357.c +6 -4
@@ -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->ndescs <HX8357_NUM_IM_PINS ) -return dev_err_probe (dev, -EINVAL ,"not enough 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" ); +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);
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Quoted 6 lines · Andy Shevchenko
The "im" pins are optional. Add missing check in the
hx8357_probe().Reported-by Dan Carpenter <[email protected]>Fixes 7d84a63a39b7 ("backlight: hx8357: Convert to agnostic GPIO API")Signed-off-by Andy Shevchenko <[email protected]>
Reviewed-by Daniel Thompson <[email protected]>
Daniel.
Re: (subset) [PATCH v1 1/1] backlight: hx8357: Fix potential NULL pointer dereference
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
The "im" pins are optional. Add missing check in the
hx8357_probe().
Applied, thanks!
[1/1] backlight: hx8357: Fix potential NULL pointer dereference
commit: 3b75d271e161e22aff8171940a77510d2fb2ad6f
--
Lee Jones [李琼斯]