]> git.baikalelectronics.ru Git - kernel.git/commitdiff
media: imx-jpeg: Fix potential array out of bounds in queue_setup
authorMirela Rabulea <mirela.rabulea@oss.nxp.com>
Tue, 8 Mar 2022 13:16:57 +0000 (14:16 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 13 May 2022 09:02:17 +0000 (11:02 +0200)
Fix smatch warning in mxc_jpeg_queue_setup, check *nplanes against
current format:

drivers/media/platform/imx-jpeg/mxc-jpeg.c:1070
mxc_jpeg_queue_setup()
         warn: potential user controlled iterator 'i' (array size 2 vs 7)

Signed-off-by: Mirela Rabulea <mirela.rabulea@oss.nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c

index 8b33a3bca867dda05469eff05359dcfd7a6f9686..87d91e9277479fd7707429cb41a0df4e889d8716 100644 (file)
@@ -1081,6 +1081,8 @@ static int mxc_jpeg_queue_setup(struct vb2_queue *q,
 
        /* Handle CREATE_BUFS situation - *nplanes != 0 */
        if (*nplanes) {
+               if (*nplanes != q_data->fmt->colplanes)
+                       return -EINVAL;
                for (i = 0; i < *nplanes; i++) {
                        if (sizes[i] < q_data->sizeimage[i])
                                return -EINVAL;