Skip to content

Commit 797cc01

Browse files
Chen Nilag-linaro
authored andcommitted
backlight: sky81452-backlight: Check return value of devm_gpiod_get_optional() in sky81452_bl_parse_dt()
The devm_gpiod_get_optional() function may return an ERR_PTR in case of genuine GPIO acquisition errors, not just NULL which indicates the legitimate absence of an optional GPIO. Add an IS_ERR() check after the call in sky81452_bl_parse_dt(). On error, return the error code to ensure proper failure handling rather than proceeding with invalid pointers. Fixes: e1915ee ("backlight: sky81452: Convert to GPIO descriptors") Signed-off-by: Chen Ni <nichen@iscas.ac.cn> Reviewed-by: Linus Walleij <linusw@kernel.org> Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org> Link: https://patch.msgid.link/20260203021625.578678-1-nichen@iscas.ac.cn Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 6de23f8 commit 797cc01

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/video/backlight/sky81452-backlight.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
202202
pdata->dpwm_mode = of_property_read_bool(np, "skyworks,dpwm-mode");
203203
pdata->phase_shift = of_property_read_bool(np, "skyworks,phase-shift");
204204
pdata->gpiod_enable = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
205+
if (IS_ERR(pdata->gpiod_enable))
206+
return dev_err_cast_probe(dev, pdata->gpiod_enable,
207+
"failed to get gpio\n");
205208

206209
ret = of_property_count_u32_elems(np, "led-sources");
207210
if (ret < 0) {

0 commit comments

Comments
 (0)