Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/dp: Use array size for intersect_rates() bound
@ 2026-08-04  8:56 Suraj Kandpal
  2026-08-04  9:17 ` Jani Nikula
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Suraj Kandpal @ 2026-08-04  8:56 UTC (permalink / raw)
  To: intel-xe, intel-gfx; +Cc: ankit.k.nautiyal, jani.nikula, Suraj Kandpal

Take an explicit common_len parameter and pass
ARRAY_SIZE(intel_dp->common_rates) at the call site, so the bound is
tied to the destination array.

Fixes: e6bda3e4cb43 ("drm/i915: Avoid overflowing the DP link rate arrays")
Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 7f13595f40c1..dd0fbb0ba20d 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -625,13 +625,13 @@ intel_dp_set_source_rates(struct intel_dp *intel_dp)
 
 static int intersect_rates(const int *source_rates, int source_len,
 			   const int *sink_rates, int sink_len,
-			   int *common_rates)
+			   int *common_rates, int common_len)
 {
 	int i = 0, j = 0, k = 0;
 
 	while (i < source_len && j < sink_len) {
 		if (source_rates[i] == sink_rates[j]) {
-			if (WARN_ON(k >= DP_MAX_SUPPORTED_RATES))
+			if (WARN_ON(k >= common_len))
 				return k;
 			common_rates[k] = source_rates[i];
 			++k;
@@ -671,7 +671,8 @@ static void intel_dp_get_common_rates(struct intel_dp *intel_dp,
 					    intel_dp->num_source_rates,
 					    intel_dp->sink_rates,
 					    intel_dp->num_sink_rates,
-					    common_rates);
+					    intel_dp->common_rates,
+					    ARRAY_SIZE(intel_dp->common_rates));
 
 	/* Paranoia, there should always be something in common. */
 	if (drm_WARN_ON(display->drm, *num_common_rates == 0)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-08-07 15:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04  8:56 [PATCH] drm/i915/dp: Use array size for intersect_rates() bound Suraj Kandpal
2026-08-04  9:17 ` Jani Nikula
2026-08-04 10:55 ` [PATCH v2] " Suraj Kandpal
2026-08-05  5:38   ` Borah, Chaitanya Kumar
2026-08-05  7:44     ` Jani Nikula
2026-08-05  8:01       ` Borah, Chaitanya Kumar
2026-08-07  2:45   ` [PATCH v3] " Suraj Kandpal
2026-08-04 11:02 ` ✓ CI.KUnit: success for drm/i915/dp: Use array size for intersect_rates() bound (rev2) Patchwork
2026-08-04 11:46 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-04 17:55 ` ✓ Xe.CI.FULL: " Patchwork
2026-08-07  2:53 ` ✓ CI.KUnit: success for drm/i915/dp: Use array size for intersect_rates() bound (rev3) Patchwork
2026-08-07  3:30 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-07 15:37 ` ✓ Xe.CI.FULL: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox