DragonFlyBSD Kernel Audit
DF-1868 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/display/dc/i2caux/aux_engine.c b/sys/dev/drm/amd/display/dc/i2caux/aux_engine.c
--- a/sys/dev/drm/amd/display/dc/i2caux/aux_engine.c
+++ b/sys/dev/drm/amd/display/dc/i2caux/aux_engine.c
@@ -416,6 +416,12 @@
 		ctx->timed_out_retry_aux = 0;
 		ctx->invalid_reply_retry_aux = 0;
 
+		/* returned_byte is the HW AUX_SW_REPLY_BYTE_COUNT register and
+		 * may exceed the 16-byte reply_data stack buffer; clamp it. */
+		if (ctx->returned_byte > DEFAULT_AUX_MAX_DATA_SIZE) {
+			ctx->returned_byte = DEFAULT_AUX_MAX_DATA_SIZE;
+		}
+
 		ctx->reply.length = ctx->returned_byte;
 		ctx->reply.data = ctx->reply_data;