diff options
author | Wu-Cheng Li | 2016-11-10 03:24:05 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab | 2016-11-16 15:27:43 -0200 |
commit | b7ccb9fb7994d0340314a5d467a8c4d3e37d6531 (patch) | |
tree | aa08c1536dcbd7a80116781756a818be9f6d79f0 /drivers/media/platform | |
parent | 93d39efdb1f8c8c4b848122b8c8ad986690fe9ba (diff) |
[media] mtk-vcodec: add index check in decoder vidioc_qbuf
vb2_qbuf will check the buffer index. If a driver overrides
vidioc_qbuf and use the buffer index, the driver needs to check
the index.
Signed-off-by: Wu-Cheng Li <wuchengli@chromium.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r-- | drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c index 05209193ff7e..074659227864 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c @@ -533,6 +533,10 @@ static int vidioc_vdec_qbuf(struct file *file, void *priv, } vq = v4l2_m2m_get_vq(ctx->m2m_ctx, buf->type); + if (buf->index >= vq->num_buffers) { + mtk_v4l2_debug(1, "buffer index %d out of range", buf->index); + return -EINVAL; + } vb = vq->bufs[buf->index]; vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf); mtkbuf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb); |