From: Baruch Siach Date: Fri, 19 Feb 2010 17:09:25 +0000 (-0300) Subject: V4L/DVB: v4l: soc_camera: fix bound checking of mbus_fmt[] index X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=84f3751d6a6f766780dee509433bf7b3dfcdf465;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git V4L/DVB: v4l: soc_camera: fix bound checking of mbus_fmt[] index When code <= V4L2_MBUS_FMT_FIXED soc_mbus_get_fmtdesc returns a pointer to mbus_fmt[x], where x < 0. Fix this. Signed-off-by: Baruch Siach Signed-off-by: Guennadi Liakhovetski CC: stable@kernel.org Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c index 0149290ee5a..8b63b6545e7 100644 --- a/drivers/media/video/soc_mediabus.c +++ b/drivers/media/video/soc_mediabus.c @@ -149,7 +149,8 @@ EXPORT_SYMBOL(soc_mbus_bytes_per_line); const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( enum v4l2_mbus_pixelcode code) { - if ((unsigned int)(code - V4L2_MBUS_FMT_FIXED) > ARRAY_SIZE(mbus_fmt)) + if (code - V4L2_MBUS_FMT_FIXED > ARRAY_SIZE(mbus_fmt) || + code <= V4L2_MBUS_FMT_FIXED) return NULL; return mbus_fmt + code - V4L2_MBUS_FMT_FIXED - 1; }