Skip to content

Commit daa3fc4

Browse files
hverkuilmchehab
authored andcommitted
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>
1 parent e714c92 commit daa3fc4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/media/platform/vicodec/vicodec-core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,11 +997,18 @@ static int vicodec_start_streaming(struct vb2_queue *q,
997997

998998
q_data->sequence = 0;
999999

1000-
if (!V4L2_TYPE_IS_OUTPUT(q->type))
1000+
if (!V4L2_TYPE_IS_OUTPUT(q->type)) {
1001+
if (!ctx->is_enc) {
1002+
state->width = q_data->width;
1003+
state->height = q_data->height;
1004+
}
10011005
return 0;
1006+
}
10021007

1003-
state->width = q_data->width;
1004-
state->height = q_data->height;
1008+
if (ctx->is_enc) {
1009+
state->width = q_data->width;
1010+
state->height = q_data->height;
1011+
}
10051012
state->ref_frame.width = state->ref_frame.height = 0;
10061013
state->ref_frame.luma = kvmalloc(size + 2 * size / chroma_div,
10071014
GFP_KERNEL);

0 commit comments

Comments
 (0)