Skip to content

Commit

Permalink
media: saa7146: fix array overflow in vidioc_s_audio()
Browse files Browse the repository at this point in the history
[ Upstream commit 8e4d86e ]

The "a->index" value comes from the user via the ioctl.  The problem is
that the shift can wrap resulting in setting "mxb->cur_audinput" to an
invalid value, which later results in an array overflow.

Fixes: 6680427 ("[media] mxb: fix audio handling")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Dec 30, 2020
1 parent bfdf000 commit b0483a3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions drivers/media/pci/saa7146/mxb.c
Expand Up @@ -641,16 +641,17 @@ static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio *
struct mxb *mxb = (struct mxb *)dev->ext_priv;

DEB_D("VIDIOC_S_AUDIO %d\n", a->index);
if (mxb_inputs[mxb->cur_input].audioset & (1 << a->index)) {
if (mxb->cur_audinput != a->index) {
mxb->cur_audinput = a->index;
tea6420_route(mxb, a->index);
if (mxb->cur_audinput == 0)
mxb_update_audmode(mxb);
}
return 0;
if (a->index >= 32 ||
!(mxb_inputs[mxb->cur_input].audioset & (1 << a->index)))
return -EINVAL;

if (mxb->cur_audinput != a->index) {
mxb->cur_audinput = a->index;
tea6420_route(mxb, a->index);
if (mxb->cur_audinput == 0)
mxb_update_audmode(mxb);
}
return -EINVAL;
return 0;
}

#ifdef CONFIG_VIDEO_ADV_DEBUG
Expand Down

0 comments on commit b0483a3

Please sign in to comment.