From: Hans Verkuil Date: Wed, 24 Aug 2022 07:00:24 +0000 (+0200) Subject: media: tc358743: limit msg.len to CEC_MAX_MSG_SIZE X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3028fb90f5b972ef9b9e68e75a8372b8f9a8e312;p=linux.git media: tc358743: 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. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index e18b8947ad7e5..804b8ee8e4aba 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -964,6 +964,8 @@ static void tc358743_cec_handler(struct v4l2_subdev *sd, u16 intstatus, v = i2c_rd32(sd, CECRCTR); msg.len = v & 0x1f; + if (msg.len > CEC_MAX_MSG_SIZE) + msg.len = CEC_MAX_MSG_SIZE; for (i = 0; i < msg.len; i++) { v = i2c_rd32(sd, CECRBUF1 + i * 4); msg.msg[i] = v & 0xff;