[Intel-gfx] [PATCH RESEND v3 3/5] drm/dp_mst: Check payload count in drm_dp_mst_atomic_check()

Lyude Paul lyude at redhat.com
Wed Nov 7 01:31:37 UTC 2018


It occurred to me that we never actually check this! So let's start
doing that.

Signed-off-by: Lyude Paul <lyude at redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 74823afb262e..8ef0c5f5c7cf 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3213,7 +3213,7 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr,
 {
 	struct drm_dp_vcpi_allocation *vcpi;
 	struct drm_dp_mst_port *port;
-	int avail_slots = 63, ret;
+	int avail_slots = 63, payload_count = 0, ret;
 
 	list_for_each_entry(vcpi, &mst_state->vcpis, next) {
 		/* Ports that no longer exist shouldn't be counted towards the
@@ -3238,6 +3238,13 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr,
 			goto port_fail;
 		}
 
+		if (++payload_count > mgr->max_payloads) {
+			DRM_DEBUG_ATOMIC("[MST MGR:%p] state %p has too many payloads (max=%d)\n",
+					 mgr, mst_state, mgr->max_payloads);
+			ret = -EINVAL;
+			goto port_fail;
+		}
+
 		drm_dp_put_port(port);
 	}
 	DRM_DEBUG_ATOMIC("[MST MGR:%p] mst_state %p vcpi avail=%d used=%d\n",
-- 
2.19.1



More information about the Intel-gfx mailing list