Commit db9a01b3 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vicodec: check type in g/s_selection

Check that the selection buf_type is valid before calling get_q_data() to
avoid hitting the WARN(1) in that function if the buffer type is not valid.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: syzbot+44b24cff6bf96006ecfa@syzkaller.appspotmail.com
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 801efd0f
...@@ -953,6 +953,9 @@ static int vidioc_g_selection(struct file *file, void *priv, ...@@ -953,6 +953,9 @@ static int vidioc_g_selection(struct file *file, void *priv,
valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
} }
if (s->type != valid_cap_type && s->type != valid_out_type)
return -EINVAL;
q_data = get_q_data(ctx, s->type); q_data = get_q_data(ctx, s->type);
if (!q_data) if (!q_data)
return -EINVAL; return -EINVAL;
...@@ -994,12 +997,14 @@ static int vidioc_s_selection(struct file *file, void *priv, ...@@ -994,12 +997,14 @@ static int vidioc_s_selection(struct file *file, void *priv,
if (multiplanar) if (multiplanar)
out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
if (s->type != out_type)
return -EINVAL;
q_data = get_q_data(ctx, s->type); q_data = get_q_data(ctx, s->type);
if (!q_data) if (!q_data)
return -EINVAL; return -EINVAL;
if (!ctx->is_enc || s->type != out_type || if (!ctx->is_enc || s->target != V4L2_SEL_TGT_CROP)
s->target != V4L2_SEL_TGT_CROP)
return -EINVAL; return -EINVAL;
s->r.left = 0; s->r.left = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment