Commit a874b6a3 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/i915: Prevent kernel panic when reading/writing compliance debugfs files, v2.

When reading all debugfs files on a system with DP-MST the kernel panics
on a null pointer dereference because intel_dp is null for a DP-MST
connector. Detect this case and skip those connectors.

Also fix the write for the DP compliance file in the same way.

Changes since v1:
- Fix i915_displayport_test_active_write too. (DK)
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Reviewed-by: default avatarDhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170626081835.24251-1-maarten.lankhorst@linux.intel.com
parent 987f8c44
...@@ -3778,13 +3778,18 @@ static ssize_t i915_displayport_test_active_write(struct file *file, ...@@ -3778,13 +3778,18 @@ static ssize_t i915_displayport_test_active_write(struct file *file,
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { drm_for_each_connector_iter(connector, &conn_iter) {
struct intel_encoder *encoder;
if (connector->connector_type != if (connector->connector_type !=
DRM_MODE_CONNECTOR_DisplayPort) DRM_MODE_CONNECTOR_DisplayPort)
continue; continue;
if (connector->status == connector_status_connected && encoder = to_intel_encoder(connector->encoder);
connector->encoder != NULL) { if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
intel_dp = enc_to_intel_dp(connector->encoder); continue;
if (encoder && connector->status == connector_status_connected) {
intel_dp = enc_to_intel_dp(&encoder->base);
status = kstrtoint(input_buffer, 10, &val); status = kstrtoint(input_buffer, 10, &val);
if (status < 0) if (status < 0)
break; break;
...@@ -3816,13 +3821,18 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data) ...@@ -3816,13 +3821,18 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data)
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { drm_for_each_connector_iter(connector, &conn_iter) {
struct intel_encoder *encoder;
if (connector->connector_type != if (connector->connector_type !=
DRM_MODE_CONNECTOR_DisplayPort) DRM_MODE_CONNECTOR_DisplayPort)
continue; continue;
if (connector->status == connector_status_connected && encoder = to_intel_encoder(connector->encoder);
connector->encoder != NULL) { if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
intel_dp = enc_to_intel_dp(connector->encoder); continue;
if (encoder && connector->status == connector_status_connected) {
intel_dp = enc_to_intel_dp(&encoder->base);
if (intel_dp->compliance.test_active) if (intel_dp->compliance.test_active)
seq_puts(m, "1"); seq_puts(m, "1");
else else
...@@ -3862,13 +3872,18 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data) ...@@ -3862,13 +3872,18 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data)
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { drm_for_each_connector_iter(connector, &conn_iter) {
struct intel_encoder *encoder;
if (connector->connector_type != if (connector->connector_type !=
DRM_MODE_CONNECTOR_DisplayPort) DRM_MODE_CONNECTOR_DisplayPort)
continue; continue;
if (connector->status == connector_status_connected && encoder = to_intel_encoder(connector->encoder);
connector->encoder != NULL) { if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
intel_dp = enc_to_intel_dp(connector->encoder); continue;
if (encoder && connector->status == connector_status_connected) {
intel_dp = enc_to_intel_dp(&encoder->base);
if (intel_dp->compliance.test_type == if (intel_dp->compliance.test_type ==
DP_TEST_LINK_EDID_READ) DP_TEST_LINK_EDID_READ)
seq_printf(m, "%lx", seq_printf(m, "%lx",
...@@ -3915,13 +3930,18 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data) ...@@ -3915,13 +3930,18 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data)
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { drm_for_each_connector_iter(connector, &conn_iter) {
struct intel_encoder *encoder;
if (connector->connector_type != if (connector->connector_type !=
DRM_MODE_CONNECTOR_DisplayPort) DRM_MODE_CONNECTOR_DisplayPort)
continue; continue;
if (connector->status == connector_status_connected && encoder = to_intel_encoder(connector->encoder);
connector->encoder != NULL) { if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
intel_dp = enc_to_intel_dp(connector->encoder); continue;
if (encoder && connector->status == connector_status_connected) {
intel_dp = enc_to_intel_dp(&encoder->base);
seq_printf(m, "%02lx", intel_dp->compliance.test_type); seq_printf(m, "%02lx", intel_dp->compliance.test_type);
} else } else
seq_puts(m, "0"); seq_puts(m, "0");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment