Commit 3b9fbe0d authored by Dan Carpenter's avatar Dan Carpenter Committed by Kleber Sacilotto de Souza

media: davinci/vpbe: array underflow in vpbe_enum_outputs()

BugLink: https://bugs.launchpad.net/bugs/1864773

[ Upstream commit b72845ee ]

In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
the problem is that "temp_index" can be negative.  This patch changes
the types to unsigned to address this array underflow bug.

Fixes: 66715cdc ("[media] davinci vpbe: VPBE display driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatar"Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 02d37ef0
...@@ -130,7 +130,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev, ...@@ -130,7 +130,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
struct v4l2_output *output) struct v4l2_output *output)
{ {
struct vpbe_config *cfg = vpbe_dev->cfg; struct vpbe_config *cfg = vpbe_dev->cfg;
int temp_index = output->index; unsigned int temp_index = output->index;
if (temp_index >= cfg->num_outputs) if (temp_index >= cfg->num_outputs)
return -EINVAL; return -EINVAL;
......
...@@ -96,7 +96,7 @@ struct vpbe_config { ...@@ -96,7 +96,7 @@ struct vpbe_config {
struct encoder_config_info *ext_encoders; struct encoder_config_info *ext_encoders;
/* amplifier information goes here */ /* amplifier information goes here */
struct amp_config_info *amp; struct amp_config_info *amp;
int num_outputs; unsigned int num_outputs;
/* Order is venc outputs followed by LCD and then external encoders */ /* Order is venc outputs followed by LCD and then external encoders */
struct vpbe_output *outputs; struct vpbe_output *outputs;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment