OSDN Git Service

media: mediatek: vcodec: return EINVAL if plane is too small
authorJustin Green <greenjustin@chromium.org>
Wed, 15 Jun 2022 15:38:27 +0000 (16:38 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 27 Jun 2022 08:11:12 +0000 (09:11 +0100)
Modify vb2ops_vdec_buf_prepare to return EINVAL if the size of the plane
is less than the size of the image. Currently we just log an error and
return 0 anyway, which may cause a buffer overrun bug.

Signed-off-by: Justin Green <greenjustin@chromium.org>
Suggested-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c

index 813dafd..c96c95a 100644 (file)
@@ -797,6 +797,7 @@ int vb2ops_vdec_buf_prepare(struct vb2_buffer *vb)
                        mtk_v4l2_err("data will not fit into plane %d (%lu < %d)",
                                i, vb2_plane_size(vb, i),
                                q_data->sizeimage[i]);
+                       return -EINVAL;
                }
                if (!V4L2_TYPE_IS_OUTPUT(vb->type))
                        vb2_set_plane_payload(vb, i, q_data->sizeimage[i]);