drm/dp: Handle zeroed port counts in drm_dp_read_downstream_info()
authorjsg <jsg@openbsd.org>
Mon, 19 Jul 2021 10:45:08 +0000 (10:45 +0000)
committerjsg <jsg@openbsd.org>
Mon, 19 Jul 2021 10:45:08 +0000 (10:45 +0000)
From Lyude Paul
2998599fb16cd99b0384d2517bbd409a233a9695 in linux 5.10.y/5.10.51
205bb69a90363541a634a662a599fddb95956524 in mainline linux

sys/dev/pci/drm/drm_dp_helper.c

index d6343f9..f568aa5 100644 (file)
@@ -602,7 +602,14 @@ int drm_dp_read_downstream_info(struct drm_dp_aux *aux,
            !(dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT))
                return 0;
 
+       /* Some branches advertise having 0 downstream ports, despite also advertising they have a
+        * downstream port present. The DP spec isn't clear on if this is allowed or not, but since
+        * some branches do it we need to handle it regardless.
+        */
        len = drm_dp_downstream_port_count(dpcd);
+       if (!len)
+               return 0;
+
        if (dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DETAILED_CAP_INFO_AVAILABLE)
                len *= 4;