From: Mauro Carvalho Chehab Date: Fri, 5 Jun 2015 11:07:19 +0000 (-0300) Subject: [media] sh_vou: avoid going past arrays X-Git-Tag: omap-for-v4.2/fixes-rc1^2~111^2~145 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ac417efe66ddd7cd70a98f7f4e32a14ae40a651;p=pandora-kernel.git [media] sh_vou: avoid going past arrays Smatch reports two issues: drivers/media/platform/sh_vou.c:670 vou_adjust_output() error: buffer overflow 'vou_scale_v_num' 3 <= 4 drivers/media/platform/sh_vou.c:670 vou_adjust_output() error: buffer overflow 'vou_scale_v_den' 3 <= 4 It seems that there's actually a bug here: the same var (idx) is used as an index for vertical and horizontal scaling arrays. However, there are 4 elements on the h arrays, and only 3 at the v ones. On the first loop, it may select index 4 for the horizontal array. In this case, if the second loop fails to select an index, the code would keep using 4 for the vertical array, with is past of the array sizes. The intent here seems to use index 0, if the scale is not found. So, use a separate var for the vertical index. Signed-off-by: Mauro Carvalho Chehab --- Reading git-diff-tree failed