mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kery Qi <qikeyu2017@gmail.com>
To: harry.wentland@amd.com
Cc: linux-kernel@vger.kernel.org, Kery Qi <qikeyu2017@gmail.com>
Subject: [PATCH] drm/amd/display: dce110: fix NULL deref in dce110_set_backlight_level()
Date: Fri,  9 Jan 2026 04:40:19 +0800	[thread overview]
Message-ID: <20260108204019.1870-1-qikeyu2017@gmail.com> (raw)

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


                 reply	other threads:[~2026-01-08 20:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260108204019.1870-1-qikeyu2017@gmail.com \
    --to=qikeyu2017@gmail.com \
    --cc=harry.wentland@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®