Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/hdmi: Fix potential overflow while using intel_encoder_to_tc
@ 2025-09-03  3:50 Ankit Nautiyal
  2025-09-03  4:41 ` ✓ CI.KUnit: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ankit Nautiyal @ 2025-09-03  3:50 UTC (permalink / raw)
  To: intel-gfx, intel-xe; +Cc: Ankit Nautiyal

The helper intel_encoder_to_tc() can potentially return TC_PORT_NONE
(-1) and cause overflow while computing ddc pins in
icl_encoder_to_ddc_pin().

Check for TC_PORT_NONE before deriving the ddc pins for TC port.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_hdmi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index cbee628eb26b..85f70cedc40c 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -2791,10 +2791,16 @@ static u8 icl_encoder_to_ddc_pin(struct intel_encoder *encoder)
 	struct intel_display *display = to_intel_display(encoder);
 	enum port port = encoder->port;
 
-	if (intel_encoder_is_combo(encoder))
+	if (intel_encoder_is_combo(encoder)) {
 		return GMBUS_PIN_1_BXT + port;
-	else if (intel_encoder_is_tc(encoder))
-		return GMBUS_PIN_9_TC1_ICP + intel_encoder_to_tc(encoder);
+	} else if (intel_encoder_is_tc(encoder)) {
+		enum tc_port tc_port = intel_encoder_to_tc(encoder);
+
+		if (tc_port != TC_PORT_NONE)
+			return GMBUS_PIN_9_TC1_ICP + tc_port;
+
+		drm_WARN(display->drm, 1, "Invalid TC port\n");
+	}
 
 	drm_WARN(display->drm, 1, "Unknown port:%c\n", port_name(port));
 	return GMBUS_PIN_2_BXT;
-- 
2.45.2


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

end of thread, other threads:[~2025-09-03 13:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03  3:50 [PATCH] drm/i915/hdmi: Fix potential overflow while using intel_encoder_to_tc Ankit Nautiyal
2025-09-03  4:41 ` ✓ CI.KUnit: success for " Patchwork
2025-09-03  5:22 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-03  7:37 ` [PATCH] " Jani Nikula
2025-09-03  9:57   ` Nautiyal, Ankit K
2025-09-03 10:16     ` Jani Nikula
2025-09-03 11:03       ` Nautiyal, Ankit K
2025-09-03 12:24 ` Kahola, Mika
2025-09-03 13:38 ` ✗ Xe.CI.Full: failure for " Patchwork

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