Commit f3aa6840 authored by Dan Carpenter's avatar Dan Carpenter Committed by Mauro Carvalho Chehab

media: staging: atomisp: array underflow in ioctl

I noticed an array underflow in ov5693_enum_frame_size().  The code
looks like this:

	int index = fse->index;

	if (index >= N_RES)
		retur -EINVAL;

fse->index is a u32 that comes from the user.  We want negative values
to be counted as -EINVAL but they aren't.  There are several ways to fix
this but I feel like the best fix for future proofing is to change the
type of N_RES from int to unsigned long to make it the same as if we
were comparing against ARRAY_SIZE().
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 9f5039ba
......@@ -454,6 +454,6 @@ struct gc0310_resolution gc0310_res_video[] = {
#define N_RES_VIDEO (ARRAY_SIZE(gc0310_res_video))
static struct gc0310_resolution *gc0310_res = gc0310_res_preview;
static int N_RES = N_RES_PREVIEW;
static unsigned long N_RES = N_RES_PREVIEW;
#endif
......@@ -668,5 +668,5 @@ struct gc2235_resolution gc2235_res_video[] = {
#define N_RES_VIDEO (ARRAY_SIZE(gc2235_res_video))
static struct gc2235_resolution *gc2235_res = gc2235_res_preview;
static int N_RES = N_RES_PREVIEW;
static unsigned long N_RES = N_RES_PREVIEW;
#endif
......@@ -934,7 +934,6 @@ static struct ov2680_resolution ov2680_res_video[] = {
#define N_RES_VIDEO (ARRAY_SIZE(ov2680_res_video))
static struct ov2680_resolution *ov2680_res = ov2680_res_preview;
static int N_RES = N_RES_PREVIEW;
static unsigned long N_RES = N_RES_PREVIEW;
#endif
......@@ -1263,5 +1263,5 @@ struct ov2722_resolution ov2722_res_video[] = {
#define N_RES_VIDEO (ARRAY_SIZE(ov2722_res_video))
static struct ov2722_resolution *ov2722_res = ov2722_res_preview;
static int N_RES = N_RES_PREVIEW;
static unsigned long N_RES = N_RES_PREVIEW;
#endif
......@@ -1377,5 +1377,5 @@ struct ov5693_resolution ov5693_res_video[] = {
#define N_RES_VIDEO (ARRAY_SIZE(ov5693_res_video))
static struct ov5693_resolution *ov5693_res = ov5693_res_preview;
static int N_RES = N_RES_PREVIEW;
static unsigned long N_RES = N_RES_PREVIEW;
#endif
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