summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2018-11-28 15:52:42 -0500
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-12-03 15:04:36 -0500
commitdaa3fc4454b21ac883152d07b4778bc4f83ec716 (patch)
treef4a42ca8edfd2e34ed7efdf0922a5e8c03b44945 /drivers/media/platform
parente714c92f42aeed6052a287b8ccf5a519e42bab15 (diff)
downloadlinux-stable-daa3fc4454b21ac883152d07b4778bc4f83ec716.tar.gz
linux-stable-daa3fc4454b21ac883152d07b4778bc4f83ec716.tar.bz2
linux-stable-daa3fc4454b21ac883152d07b4778bc4f83ec716.zip
media: vicodec: set state resolution from raw format
The state structure contains the resolution expected by the decoder and encoder. For an encoder that resolution should be taken from the OUTPUT format, and for a decoder from the CAPTURE format. If the wrong format is picked, a buffer overrun can occur if there is a mismatch between the CAPTURE and OUTPUT formats. The real fix would be to correctly implement the stateful codec specification, but that will take more time. For now just prevent the buffer overrun. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/vicodec/vicodec-core.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c
index 013cdebecbc4..13fb69c58967 100644
--- a/drivers/media/platform/vicodec/vicodec-core.c
+++ b/drivers/media/platform/vicodec/vicodec-core.c
@@ -997,11 +997,18 @@ static int vicodec_start_streaming(struct vb2_queue *q,
q_data->sequence = 0;
- if (!V4L2_TYPE_IS_OUTPUT(q->type))
+ if (!V4L2_TYPE_IS_OUTPUT(q->type)) {
+ if (!ctx->is_enc) {
+ state->width = q_data->width;
+ state->height = q_data->height;
+ }
return 0;
+ }
- state->width = q_data->width;
- state->height = q_data->height;
+ if (ctx->is_enc) {
+ state->width = q_data->width;
+ state->height = q_data->height;
+ }
state->ref_frame.width = state->ref_frame.height = 0;
state->ref_frame.luma = kvmalloc(size + 2 * size / chroma_div,
GFP_KERNEL);