mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: dce110: fix NULL deref in dce110_set_backlight_level()
@ 2026-01-08 20:40 Kery Qi
  0 siblings, 0 replies; only message in thread
From: Kery Qi @ 2026-01-08 20:40 UTC (permalink / raw)
  To: harry.wentland; +Cc: linux-kernel, Kery Qi

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 <qikeyu2017@gmail.com>
---
 drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
index 0cdd8c74abdf..6177bc67ea9c 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
@@ -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;
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-01-08 20:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-08 20:40 [PATCH] drm/amd/display: dce110: fix NULL deref in dce110_set_backlight_level() Kery Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®