Skip to content

Commit c2fd39d

Browse files
Dan Carpenterksacilotto
authored andcommitted
media: saa7146: fix array overflow in vidioc_s_audio()
BugLink: https://bugs.launchpad.net/bugs/1910822 [ 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> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
1 parent 1c3afba commit c2fd39d

File tree

1 file changed

+10
-9
lines changed
  • drivers/media/pci/saa7146

1 file changed

+10
-9
lines changed

drivers/media/pci/saa7146/mxb.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -641,16 +641,17 @@ static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio *
641641
struct mxb *mxb = (struct mxb *)dev->ext_priv;
642642

643643
DEB_D("VIDIOC_S_AUDIO %d\n", a->index);
644-
if (mxb_inputs[mxb->cur_input].audioset & (1 << a->index)) {
645-
if (mxb->cur_audinput != a->index) {
646-
mxb->cur_audinput = a->index;
647-
tea6420_route(mxb, a->index);
648-
if (mxb->cur_audinput == 0)
649-
mxb_update_audmode(mxb);
650-
}
651-
return 0;
644+
if (a->index >= 32 ||
645+
!(mxb_inputs[mxb->cur_input].audioset & (1 << a->index)))
646+
return -EINVAL;
647+
648+
if (mxb->cur_audinput != a->index) {
649+
mxb->cur_audinput = a->index;
650+
tea6420_route(mxb, a->index);
651+
if (mxb->cur_audinput == 0)
652+
mxb_update_audmode(mxb);
652653
}
653-
return -EINVAL;
654+
return 0;
654655
}
655656

656657
#ifdef CONFIG_VIDEO_ADV_DEBUG

0 commit comments

Comments
 (0)