[PATCH v2 04/25] drm/display: hdmi-state-helper: Reject connectors lacking HDMI funcs
From: Cristian Ciocaltea
Date: Tue Dec 01 2026 - 21:20:38 EST
Connectors not initialized via drmm_connector_hdmi_init() may still end
up in drm_atomic_helper_connector_hdmi_check(), e.g. when a driver
reuses parts of the HDMI state helpers. Such connectors used to fail
gracefully: with max_bpc and supported_formats both zero,
hdmi_compute_config() found no usable format/bpc combination and
returned -EINVAL before hdmi_generate_infoframes() dereferenced
hdmi.funcs.
Upcoming changes replace the max_bpc and supported_formats fields with
drm_connector_hdmi_funcs counterparts, which would cause a NULL pointer
dereference in hdmi_compute_config() for such connectors. Preserve the
existing behaviour by returning -EINVAL early when hdmi.funcs is not
set, along with a debug message, instead of running the format/bpc
computation only to have it fail with misleading messages.
While at it, fix an indentation issue in a later drm_dbg_kms() call.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@xxxxxxxxxxxxx>
---
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index c50cedc7fa65..37f4810db7c6 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -676,12 +676,18 @@ hdmi_compute_config(const struct drm_connector *connector,
struct drm_connector_state *conn_state,
const struct drm_display_mode *mode)
{
- unsigned int max_bpc = clamp_t(unsigned int,
- conn_state->max_bpc,
- 8, connector->max_bpc);
enum drm_output_color_format fmt;
+ unsigned int max_bpc;
int ret;
+ if (!connector->hdmi.funcs) {
+ drm_dbg_kms(connector->dev, "Missing HDMI connector funcs.\n");
+ return -EINVAL;
+ }
+
+ max_bpc = clamp_t(unsigned int, conn_state->max_bpc,
+ 8, connector->max_bpc);
+
if (conn_state->color_format != DRM_CONNECTOR_COLOR_FORMAT_AUTO) {
switch (conn_state->color_format) {
case DRM_CONNECTOR_COLOR_FORMAT_AUTO:
@@ -701,7 +707,7 @@ hdmi_compute_config(const struct drm_connector *connector,
break;
default:
drm_dbg_kms(connector->dev, "HDMI does not support color format '%d'.\n",
- conn_state->color_format);
+ conn_state->color_format);
return -EINVAL;
}
--
2.56.0