[Intel-gfx] [PATCH 2/5] drm/i915: WARN if the DP aux read is too big

Paulo Zanoni przanoni at gmail.com
Thu Sep 12 18:58:18 CEST 2013


From: Paulo Zanoni <paulo.r.zanoni at intel.com>

So far we control all the reads an none of them exceeds the current
limit of 20 bytes, but we never think about this when reviewing
patches, so add a big WARN. In case we ever hit that WARN, we whould
change the size of the reply array.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
 drivers/gpu/drm/i915/intel_dp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 20e468c..f30b691 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -577,6 +577,8 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
 
 	msg_bytes = 4;
 	reply_bytes = recv_bytes + 1;
+	if (WARN_ON(reply_bytes > sizeof(reply)))
+		return -E2BIG;
 
 	for (;;) {
 		ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes,
-- 
1.8.3.1




More information about the Intel-gfx mailing list