[Intel-gfx] [PATCH 5/6] drm/dp_mst: Check payload count in ->atomic_check()

Daniel Vetter daniel at ffwll.ch
Wed Oct 24 08:54:43 UTC 2018


On Tue, Oct 23, 2018 at 07:12:50PM -0400, Lyude Paul wrote:
> 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>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index adb4298570cc..cafb769a4ec3 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -3225,7 +3225,7 @@ static int drm_dp_mst_atomic_check(struct drm_private_obj *obj,
>  		to_dp_mst_topology_state(state);
>  	struct drm_dp_mst_topology_mgr *mgr = mst_state->mgr;
>  	struct drm_dp_vcpi_allocation *pos;
> -	int avail_slots = 63;
> +	int avail_slots = 63, payload_count = 0;
>  
>  	list_for_each_entry(pos, &mst_state->vcpis, next) {
>  		DRM_DEBUG_ATOMIC("[MST PORT:%p] requires %d vcpi slots\n",
> @@ -3238,6 +3238,12 @@ static int drm_dp_mst_atomic_check(struct drm_private_obj *obj,
>  					 avail_slots + pos->vcpi);
>  			return -ENOSPC;
>  		}
> +
> +		if (++payload_count > mgr->max_payloads) {
> +			DRM_DEBUG_ATOMIC("[MST MGR:%p] state %p has too many payloads (max=%d)\n",
> +					 mgr, state, mgr->max_payloads);
> +			return -EINVAL;
> +		}

drm_dp_init_vcpi() shouldn't ever fail on atomic drivers, so maybe worth
adding a check to that effect? Probably only after amdgpu is converted
over too.

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

>  	}
>  	DRM_DEBUG_ATOMIC("[MST MGR:%p] state %p vcpi avail=%d used=%d\n",
>  			 mgr, state, avail_slots, 63 - avail_slots);
> -- 
> 2.17.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list