risc-v/mpfs: i2c: prevent out of bounds read access

priv->msgid may grow past its boundaries, causing
struct i2c_msg_s *msg = &priv->msgv[priv->msgid]
to read data out of boundaris.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
This commit is contained in:
Eero Nurkkala 2023-11-06 17:25:13 +02:00 committed by Xiang Xiao
parent 38f8aae3be
commit b0cef9e008
1 changed files with 8 additions and 2 deletions

View File

@ -493,7 +493,10 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)
/* Jump to the next message */
priv->msgid++;
if (priv->msgid < (priv->msgc - 1))
{
priv->msgid++;
}
}
else
{
@ -512,7 +515,10 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)
/* Jump to the next message */
priv->msgid++;
if (priv->msgid < (priv->msgc - 1))
{
priv->msgid++;
}
}
else
{