media: s5p_cec: limit msg.len to CEC_MAX_MSG_SIZE
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 24 Aug 2022 07:02:42 +0000 (09:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2022 14:46:06 +0000 (15:46 +0100)
[ Upstream commit 93f65ce036863893c164ca410938e0968964b26c ]

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 <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/media/s5p-cec/s5p_cec.c

index bebd44d9bd51a5b71dbf475ed5f549f507484de3..f6d1d98431a778eb1db4b0b8698d4b1ec7f7fea7 100644 (file)
@@ -112,6 +112,8 @@ static irqreturn_t s5p_cec_irq_handler(int irq, void *priv)
                                dev_dbg(cec->dev, "Buffer overrun (worker did not process previous message)\n");
                        cec->rx = STATE_BUSY;
                        cec->msg.len = status >> 24;
+                       if (cec->msg.len > CEC_MAX_MSG_SIZE)
+                               cec->msg.len = CEC_MAX_MSG_SIZE;
                        cec->msg.rx_status = CEC_RX_STATUS_OK;
                        s5p_cec_get_rx_buf(cec, cec->msg.len,
                                        cec->msg.msg);