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

Signed-off-by: Lyude Paul <ly...@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vet...@ffwll.ch>
Cc: David Airlie <airl...@redhat.com>
Cc: Jerry Zuo <jerry....@amd.com>
Cc: Harry Wentland <harry.wentl...@amd.com>
Cc: Juston Li <juston...@intel.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index b55b58bf86ba..455fcf0a82df 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3061,8 +3061,6 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state 
*state,
        if (port == NULL)
                return -EINVAL;
 
-       topology_state->vcpi_allocated = true;
-
        /* Find the current allocation for this port, if any */
        list_for_each_entry(pos, &topology_state->vcpis, next) {
                if (pos->port == port) {
@@ -3599,7 +3597,6 @@ drm_dp_mst_duplicate_state(struct drm_private_obj *obj)
        __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base);
 
        INIT_LIST_HEAD(&state->vcpis);
-       state->vcpi_allocated = false;
 
        list_for_each_entry(pos, &old_state->vcpis, next) {
                /* Prune leftover freed VCPI allocations */
@@ -3648,7 +3645,7 @@ drm_dp_mst_atomic_check_topology_state(struct 
drm_dp_mst_topology_mgr *mgr,
                                       struct drm_dp_mst_topology_state 
*mst_state)
 {
        struct drm_dp_vcpi_allocation *vcpi;
-       int avail_slots = 63;
+       int avail_slots = 63, payload_count = 0;
 
        list_for_each_entry(vcpi, &mst_state->vcpis, next) {
                /* Releasing VCPI is always OK-even if the port is gone */
@@ -3669,6 +3666,12 @@ drm_dp_mst_atomic_check_topology_state(struct 
drm_dp_mst_topology_mgr *mgr,
                        return -ENOSPC;
                }
 
+               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);
+                       return -EINVAL;
+               }
+
        }
        DRM_DEBUG_ATOMIC("[MST MGR:%p] mst state %p VCPI avail=%d used=%d\n",
                         mgr, mst_state, avail_slots,
-- 
2.19.2

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to