mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/scdc-helper: check state for NULL before taking state->scdc
@ 2026-11-28 22:29 TAKANO Mitsuhiro via B4 Relay
  0 siblings, 0 replies; only message in thread
From: TAKANO Mitsuhiro via B4 Relay @ 2026-11-28 22:29 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, TAKANO Mitsuhiro

From: TAKANO Mitsuhiro <takano32@gmail.com>

In drm_scdc_read_state(), buf is initialized to state->scdc before state
is checked for NULL. Evaluating state->scdc when state is NULL is
undefined behavior and allows the compiler to assume state is non-NULL.

Assign buf after verifying that state and connector are non-NULL.

Fixes: 6c5121962ec0 ("drm/scdc-helper: Add scdc_status debugfs entry")
Signed-off-by: TAKANO Mitsuhiro <takano32@gmail.com>
---
Verification: compile-tested on x86_64 with CONFIG_DRM_DISPLAY_HELPER=m
and CONFIG_DRM_DISPLAY_HDMI_HELPER=y (make W=1
drivers/gpu/drm/display/drm_scdc_helper.o; 0 warnings) and checked with
scripts/checkpatch.pl --strict. Checked against linux-next (next-20261127)
and lore.kernel.org for duplicates. Not runtime-tested on HDMI hardware.

The change and the changelog text were produced with an AI coding
assistant (Gemini) working from the tree; I reviewed the diff and the
reasoning, and I am responsible for the submission.
---
 drivers/gpu/drm/display/drm_scdc_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/display/drm_scdc_helper.c b/drivers/gpu/drm/display/drm_scdc_helper.c
index 74388481f..9a0300092 100644
--- a/drivers/gpu/drm/display/drm_scdc_helper.c
+++ b/drivers/gpu/drm/display/drm_scdc_helper.c
@@ -428,13 +428,14 @@ int drm_scdc_read_state(struct drm_connector *connector, struct drm_scdc_state *
 {
 	struct i2c_adapter *ddc;
 	struct drm_scdc *scdc;
-	u8 *buf = state->scdc;
+	u8 *buf;
 	int num_lanes;
 	int ret;
 
 	if (!state || !connector)
 		return -ENODEV;
 
+	buf = state->scdc;
 	scdc = &connector->display_info.hdmi.scdc;
 	ddc = connector->ddc;
 

---
base-commit: f93eb7cfc4bfa5d46340f360873726e3e77f2365
change-id: 20261128-b4-drm-scdc-null-check-8017240e3b9d

Best regards,
--  
TAKANO Mitsuhiro <takano32@gmail.com>



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

only message in thread, other threads:[~2026-11-28 22:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 22:29 [PATCH] drm/scdc-helper: check state for NULL before taking state->scdc TAKANO Mitsuhiro via B4 Relay

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®