Skip to contentSkip to conversation

cros-ec-cec: limit msg.len to CEC_MAX_MSG_SIZE

PATCH New Hans Verkuil 1 participant 1 message Aug 24, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cros-ec-cec: limit msg.len to CEC_MAX_MSG_SIZE

I expect that the hardware will have limited this to 16, but just in case it hasn't, check for this corner case.

---

drivers/media/cec/platform/cros-ec/cros-ec-cec.c +2 -0
index 3b583ed4da9d..e5ebaa58be45 100644
@@ -44,6 +44,8 @@ static void handle_cec_message(struct cros_ec_cec *cros_ec_cec)
 	uint8_t *cec_message = cros_ec->event_data.data.cec_message;
 	unsigned int len = cros_ec->event_size;
 
+	if (len > CEC_MAX_MSG_SIZE)
+		len = CEC_MAX_MSG_SIZE;
 	cros_ec_cec->rx_msg.len = len;
 	memcpy(cros_ec_cec->rx_msg.msg, cec_message, len);