public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Lyude Paul <lyude@redhat.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	nouveau@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH v2 3/4] drm/dp_mst: Check payload count in drm_dp_mst_atomic_check()
Date: Fri, 26 Oct 2018 16:35:48 -0400	[thread overview]
Message-ID: <20181026203549.1796-4-lyude@redhat.com> (raw)
In-Reply-To: <20181026203549.1796-1-lyude@redhat.com>

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

Signed-off-by: Lyude Paul <lyude@redhat.com>
Cc: Daniel Vetter <daniel.vetter@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 dcfab7536914..8bb03700e199 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3238,7 +3238,7 @@ int drm_dp_mst_atomic_check(struct drm_dp_mst_topology_state *state)
 {
 	struct drm_dp_mst_topology_mgr *mgr = state->mgr;
 	struct drm_dp_vcpi_allocation *pos;
-	int avail_slots = 63;
+	int avail_slots = 63, payload_count = 0;
 
 	list_for_each_entry(pos, &state->vcpis, next) {
 		DRM_DEBUG_ATOMIC("[MST PORT:%p] requires %d vcpi slots\n",
@@ -3251,6 +3251,12 @@ int drm_dp_mst_atomic_check(struct drm_dp_mst_topology_state *state)
 					 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_DEBUG_ATOMIC("[MST MGR:%p] state %p vcpi avail=%d used=%d\n",
 			 mgr, state, avail_slots, 63 - avail_slots);
-- 
2.17.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-10-26 20:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 20:35 [PATCH v2 0/4] drm/dp_mst: Improve VCPI helpers, use in nouveau Lyude Paul
     [not found] ` <20181026203549.1796-1-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-10-26 20:35   ` [PATCH v2 1/4] drm/dp_mst: Add some atomic state iterator macros Lyude Paul
2018-10-29 14:08     ` Daniel Vetter
2018-10-26 20:35   ` [PATCH v2 2/4] drm/dp_mst: Start tracking per-port VCPI allocations Lyude Paul
2018-10-29 14:24     ` Daniel Vetter
2018-10-29 16:43       ` Lyude Paul
     [not found]       ` <20181029142429.GB21967-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-10-30  9:04         ` Daniel Vetter
2018-10-26 20:35 ` Lyude Paul [this message]
2018-10-29 14:25   ` [PATCH v2 3/4] drm/dp_mst: Check payload count in drm_dp_mst_atomic_check() Daniel Vetter
2018-10-29 15:34     ` Lyude Paul
2018-10-26 20:35 ` [PATCH v2 4/4] drm/nouveau: Use atomic VCPI helpers for MST Lyude Paul
2018-10-29 14:11   ` Daniel Vetter
2018-10-26 22:12 ` ✗ Fi.CI.CHECKPATCH: warning for drm/dp_mst: Improve VCPI helpers, use in nouveau (rev2) Patchwork
2018-10-26 22:32 ` ✓ Fi.CI.BAT: success " Patchwork
2018-10-27  6:29 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181026203549.1796-4-lyude@redhat.com \
    --to=lyude@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=nouveau@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox