drm/dp: Don't trust drm_dp_downstream_id()
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 20 Jul 2017 17:45:32 +0000 (18:45 +0100)
committerJani Nikula <jani.nikula@intel.com>
Fri, 21 Jul 2017 14:45:26 +0000 (17:45 +0300)
Before we interpret drm_dp_downstream_id() as a string, make sure it is
NULL terminated, even when drm_dp_downtsream_id() fails.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101660
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170720174532.23377-2-chris@chris-wilson.co.uk
drivers/gpu/drm/drm_dp_helper.c

index 1d9e30f0dbf83f44fb4ffe4d394e797a5d9ad1ac..08af8d6b844b67e0653f93c5dc012706d9a13b19 100644 (file)
@@ -544,7 +544,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
                                 DP_DETAILED_CAP_INFO_AVAILABLE;
        int clk;
        int bpc;
-       char id[6];
+       char id[7];
        int len;
        uint8_t rev[2];
        int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
@@ -583,6 +583,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
                seq_puts(m, "\t\tType: N/A\n");
        }
 
+       memset(id, 0, sizeof(id));
        drm_dp_downstream_id(aux, id);
        seq_printf(m, "\t\tID: %s\n", id);