drm/amd/display: dce110: fix NULL deref in dce110_set_backlight_level()
Subsystems (3)
PATCH 1/1 drm/amd/display: dce110: fix NULL deref in dce110_set_backlight_level()
dce110_set_backlight_level() computes controller_id from pipe_ctx->stream_res.tg->inst before validating that tg is present. pipe_ctx->stream_res.tg may be NULL on some paths, which can lead to a NULL pointer dereference (oops/DoS) when setting backlight.
Fix this by requiring tg to be present before accessing tg->inst. Also check abm->funcs before dereferencing function pointers.
Fixes 4b0e95d1838f ("drm/amd/display: Add set backlight to hw sequencer.")
Signed-off-by Kery Qi <[email protected]>
--- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +6 -1
@@ -3263,10 +3263,15 @@ bool dce110_set_backlight_level(struct pipe_ctx *pipe_ctx,struct panel_cntl *panel_cntl = link->panel_cntl;struct dmcu *dmcu = dc->res_pool->dmcu;bool fw_set_brightness = true; +struct timing_generator *tg = pipe_ctx->stream_res.tg; + +if (!tg) +return false; +/* DMCU -1 for all controller id values, * therefore +1 here */ -uint32_t controller_id = pipe_ctx->stream_res.tg->inst +1 ; +uint32_t controller_id = tg->inst +1 ;if (abm ==NULL || panel_cntl ==NULL || (abm->funcs->set_backlight_level_pwm ==NULL ))return false;
Signature · 1 line
2.34.1