Skip to content

Commit 36cd744

Browse files
committed
drm/i915: check connector->encoder before using it.
DP MST will need connectors that aren't connected to specific encoders, add some checks in advance to avoid oopses. Reviewed-by: Todd Previte <tprevite@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 44905a2 commit 36cd744

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,13 +2209,15 @@ static void intel_connector_info(struct seq_file *m,
22092209
seq_printf(m, "\tCEA rev: %d\n",
22102210
connector->display_info.cea_rev);
22112211
}
2212-
if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT ||
2213-
intel_encoder->type == INTEL_OUTPUT_EDP)
2214-
intel_dp_info(m, intel_connector);
2215-
else if (intel_encoder->type == INTEL_OUTPUT_HDMI)
2216-
intel_hdmi_info(m, intel_connector);
2217-
else if (intel_encoder->type == INTEL_OUTPUT_LVDS)
2218-
intel_lvds_info(m, intel_connector);
2212+
if (intel_encoder) {
2213+
if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT ||
2214+
intel_encoder->type == INTEL_OUTPUT_EDP)
2215+
intel_dp_info(m, intel_connector);
2216+
else if (intel_encoder->type == INTEL_OUTPUT_HDMI)
2217+
intel_hdmi_info(m, intel_connector);
2218+
else if (intel_encoder->type == INTEL_OUTPUT_LVDS)
2219+
intel_lvds_info(m, intel_connector);
2220+
}
22192221

22202222
seq_printf(m, "\tmodes:\n");
22212223
list_for_each_entry(mode, &connector->modes, head)

drivers/gpu/drm/i915/i915_irq.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,8 @@ static void i915_hotplug_work_func(struct work_struct *work)
11651165
dev_priv->hpd_event_bits = 0;
11661166
list_for_each_entry(connector, &mode_config->connector_list, head) {
11671167
intel_connector = to_intel_connector(connector);
1168+
if (!intel_connector->encoder)
1169+
continue;
11681170
intel_encoder = intel_connector->encoder;
11691171
if (intel_encoder->hpd_pin > HPD_NONE &&
11701172
dev_priv->hpd_stats[intel_encoder->hpd_pin].hpd_mark == HPD_MARK_DISABLED &&
@@ -1195,6 +1197,8 @@ static void i915_hotplug_work_func(struct work_struct *work)
11951197

11961198
list_for_each_entry(connector, &mode_config->connector_list, head) {
11971199
intel_connector = to_intel_connector(connector);
1200+
if (!intel_connector->encoder)
1201+
continue;
11981202
intel_encoder = intel_connector->encoder;
11991203
if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) {
12001204
if (intel_encoder->hot_plug)

drivers/gpu/drm/i915/intel_display.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5003,20 +5003,23 @@ static void intel_connector_check_state(struct intel_connector *connector)
50035003
"wrong connector dpms state\n");
50045004
WARN(connector->base.encoder != &encoder->base,
50055005
"active connector not linked to encoder\n");
5006-
WARN(!encoder->connectors_active,
5007-
"encoder->connectors_active not set\n");
50085006

5009-
encoder_enabled = encoder->get_hw_state(encoder, &pipe);
5010-
WARN(!encoder_enabled, "encoder not enabled\n");
5011-
if (WARN_ON(!encoder->base.crtc))
5012-
return;
5007+
if (encoder) {
5008+
WARN(!encoder->connectors_active,
5009+
"encoder->connectors_active not set\n");
5010+
5011+
encoder_enabled = encoder->get_hw_state(encoder, &pipe);
5012+
WARN(!encoder_enabled, "encoder not enabled\n");
5013+
if (WARN_ON(!encoder->base.crtc))
5014+
return;
50135015

5014-
crtc = encoder->base.crtc;
5016+
crtc = encoder->base.crtc;
50155017

5016-
WARN(!crtc->enabled, "crtc not enabled\n");
5017-
WARN(!to_intel_crtc(crtc)->active, "crtc not active\n");
5018-
WARN(pipe != to_intel_crtc(crtc)->pipe,
5019-
"encoder active on the wrong pipe\n");
5018+
WARN(!crtc->enabled, "crtc not enabled\n");
5019+
WARN(!to_intel_crtc(crtc)->active, "crtc not active\n");
5020+
WARN(pipe != to_intel_crtc(crtc)->pipe,
5021+
"encoder active on the wrong pipe\n");
5022+
}
50205023
}
50215024
}
50225025

0 commit comments

Comments
 (0)