DragonFlyBSD Kernel Audit
DF-1938 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c b/sys/dev/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c
--- a/sys/dev/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c
+++ b/sys/dev/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c
@@ -289,6 +289,12 @@
 	*sw_status = REG_GET(AUX_SW_STATUS, AUX_SW_REPLY_BYTE_COUNT,
 			     &bytes_replied);
 
+	/* bytes_replied is HW AUX_SW_REPLY_BYTE_COUNT (5 bits, up to 31);
+	 * cap to DEFAULT_AUX_MAX_DATA_SIZE before the if (bytes_replied > size)
+	 * check, since size may equal the same HW field on the write path. */
+	if (bytes_replied > DEFAULT_AUX_MAX_DATA_SIZE)
+		bytes_replied = DEFAULT_AUX_MAX_DATA_SIZE;
+
 	/* In case HPD is LOW, exit AUX transaction */
 	if ((*sw_status & AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK))
 		return -1;