* [PATCH] drm/display: hdmi: Prevent NULL pointer dereference in sync_scdc()
@ 2026-10-01 22:26 Cristian Ciocaltea
2026-11-04 13:36 ` Cristian Ciocaltea
0 siblings, 1 reply; 2+ messages in thread
From: Cristian Ciocaltea @ 2026-10-01 22:26 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter
Cc: kernel, dri-devel, linux-kernel, Dan Carpenter
The connector pointer is used to initialize the local variables hdmi and
dev before the NULL check takes place, leading to the following Smatch
complaint:
drivers/gpu/drm/display/drm_hdmi_helper.c:663 drm_connector_hdmi_sync_scdc()
warn: variable dereferenced before check 'connector' (see line 657)
Move those initializations after the sanity check to avoid a potential
NULL pointer dereference.
Fixes: d653818324ed ("drm/display: hdmi: Add HDMI 2.0 scrambling management helpers")
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/all/arJo7A7L5hud3tyc@stanley.mountain/
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/display/drm_hdmi_helper.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_hdmi_helper.c b/drivers/gpu/drm/display/drm_hdmi_helper.c
index f85cce3d6254..872f7e32e8d2 100644
--- a/drivers/gpu/drm/display/drm_hdmi_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_helper.c
@@ -653,9 +653,9 @@ EXPORT_SYMBOL(drm_connector_hdmi_disable_scrambling);
int drm_connector_hdmi_sync_scdc(struct drm_connector *connector, bool plugged,
struct drm_modeset_acquire_ctx *ctx)
{
- struct drm_connector_hdmi *hdmi = &connector->hdmi;
- struct drm_device *dev = connector->dev;
+ struct drm_connector_hdmi *hdmi;
struct drm_connector_state *conn_state;
+ struct drm_device *dev;
struct drm_crtc *crtc;
u8 config;
int ret;
@@ -663,6 +663,9 @@ int drm_connector_hdmi_sync_scdc(struct drm_connector *connector, bool plugged,
if (!connector || !plugged || !ctx)
return 0;
+ hdmi = &connector->hdmi;
+ dev = connector->dev;
+
/*
* This is normally part of .detect_ctx() call path, which already holds
* connection_mutex through @ctx. However, re-acquiring it with the
---
base-commit: 37b346eab23aead52d17a8fa687056bfc651a416
change-id: 20261002-hdmi-sync-scdc-fix-deref-1813077dd48a
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] drm/display: hdmi: Prevent NULL pointer dereference in sync_scdc()
2026-10-01 22:26 [PATCH] drm/display: hdmi: Prevent NULL pointer dereference in sync_scdc() Cristian Ciocaltea
@ 2026-11-04 13:36 ` Cristian Ciocaltea
0 siblings, 0 replies; 2+ messages in thread
From: Cristian Ciocaltea @ 2026-11-04 13:36 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter
Cc: kernel, dri-devel, linux-kernel, Dan Carpenter
Hi,
On 10/2/26 1:26 AM, Cristian Ciocaltea wrote:
> The connector pointer is used to initialize the local variables hdmi and
> dev before the NULL check takes place, leading to the following Smatch
> complaint:
>
> drivers/gpu/drm/display/drm_hdmi_helper.c:663 drm_connector_hdmi_sync_scdc()
> warn: variable dereferenced before check 'connector' (see line 657)
>
> Move those initializations after the sanity check to avoid a potential
> NULL pointer dereference.
>
> Fixes: d653818324ed ("drm/display: hdmi: Add HDMI 2.0 scrambling management helpers")
There are a couple of additional fixes on top of this one, which is why I've
sent them together as part of a new series:
https://lore.kernel.org/all/20261104-hdmi-scdc-scramb-fixes-v1-0-16a9bb3d64a6@collabora.com/
Thanks,
Cristian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-04 13:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 22:26 [PATCH] drm/display: hdmi: Prevent NULL pointer dereference in sync_scdc() Cristian Ciocaltea
2026-11-04 13:36 ` Cristian Ciocaltea
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®