drm/dp_mst: Check payload count in drm_dp_mst_atomic_check()

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

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Airlie <airlied@redhat.com>
Cc: Jerry Zuo <Jerry.Zuo@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Juston Li <juston.li@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190111005343.17443-20-lyude@redhat.com
This commit is contained in:
Lyude Paul 2019-01-10 19:53:42 -05:00
parent eceae14724
commit 5e187a0142
1 changed files with 7 additions and 1 deletions

View File

@ -3641,7 +3641,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_mst_topology_state *mst_state)
{ {
struct drm_dp_vcpi_allocation *vcpi; 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) { list_for_each_entry(vcpi, &mst_state->vcpis, next) {
/* Releasing VCPI is always OK-even if the port is gone */ /* Releasing VCPI is always OK-even if the port is gone */
@ -3661,6 +3661,12 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr,
avail_slots + vcpi->vcpi); avail_slots + vcpi->vcpi);
return -ENOSPC; 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", DRM_DEBUG_ATOMIC("[MST MGR:%p] mst state %p VCPI avail=%d used=%d\n",
mgr, mst_state, avail_slots, mgr, mst_state, avail_slots,