Skip to content

Commit 115b7ac

Browse files
Dan Carpentermchehab
authored andcommitted
media: atomisp2: array underflow in ap1302_enum_frame_size()
The problem is this code from ap1302_enum_frame_size(): 738 int index = fse->index; 739 740 mutex_lock(&dev->input_lock); 741 context = ap1302_get_context(sd); 742 if (index >= dev->cntx_res[context].res_num) { 743 mutex_unlock(&dev->input_lock); 744 return -EINVAL; 745 } 746 747 res_table = dev->cntx_res[context].res_table; 748 fse->min_width = res_table[index].width; "fse->index" is a u32 that come from the user. We want negative values of "index" to be treated as -EINVAL but they're not so we can read from before the start of the res_table[] array. I've fixed this by making "res_num" a u32. I made "cur_res" a u32 as well, just for consistency. Fixes: a49d253 ("staging/atomisp: Add support for the Intel IPU v2") 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>
1 parent 7b065c5 commit 115b7ac

File tree

1 file changed

+2
-2
lines changed
  • drivers/staging/media/atomisp/i2c

1 file changed

+2
-2
lines changed

drivers/staging/media/atomisp/i2c/ap1302.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ struct ap1302_res_struct {
158158
};
159159

160160
struct ap1302_context_res {
161-
s32 res_num;
162-
s32 cur_res;
161+
u32 res_num;
162+
u32 cur_res;
163163
struct ap1302_res_struct *res_table;
164164
};
165165

0 commit comments

Comments
 (0)