]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
media: staging: atomisp: array underflow in ioctl
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 17 Jul 2017 07:58:54 +0000 (04:58 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 26 Jul 2017 09:46:42 +0000 (05:46 -0400)
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: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/staging/media/atomisp/i2c/gc0310.h
drivers/staging/media/atomisp/i2c/gc2235.h
drivers/staging/media/atomisp/i2c/ov2680.h
drivers/staging/media/atomisp/i2c/ov2722.h
drivers/staging/media/atomisp/i2c/ov5693/ov5693.h

index f31eb277f5428f98711ea235bc9dca1ba7ba1a1f..7d8a0aeecb6c1f20998d2c0f334a97aa004d4ac9 100644 (file)
@@ -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
 
index ccbc757045a5560d53fee7ff6349b1ddfe9f16c9..7c3d994180cc110515a2815a62d5cb0b9ba41aa0 100644 (file)
@@ -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
index 944fe8e3bcbf2e275c13c117a4323f0fbd00abba..ab8907e6c9efa1e20b9def2f8f5dff3a4318984c 100644 (file)
@@ -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
index b0d40965d89e6ec9a0a3b8dfbbdf1a72514dd388..73ecb167971896f6f7b5e64a3cf069ac4cf5938d 100644 (file)
@@ -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
index d88ac1777d86bcbf1d800f5c2e5d7f25f8850a40..8c2e6794463bc5bd47b476c1093ba9e9cb8a2d8f 100644 (file)
@@ -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