Skip to content

Commit 3208e45

Browse files
jhovoldgregkh
authored andcommitted
cx231xx-audio: fix NULL-deref at probe
commit 65f921647f4c89a2068478c89691f39b309b58f7 upstream. Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints. Fixes: e0d3baf ("V4L/DVB (10954): Add cx231xx USB driver") Cc: Sri Deevi <Srinivasa.Deevi@conexant.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bd14c18 commit 3208e45

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

drivers/media/usb/cx231xx/cx231xx-audio.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,11 @@ static int cx231xx_audio_init(struct cx231xx *dev)
698698
hs_config_info[0].interface_info.
699699
audio_index + 1];
700700

701+
if (uif->altsetting[0].desc.bNumEndpoints < isoc_pipe + 1) {
702+
err = -ENODEV;
703+
goto err_free_card;
704+
}
705+
701706
adev->end_point_addr =
702707
uif->altsetting[0].endpoint[isoc_pipe].desc.
703708
bEndpointAddress;
@@ -713,8 +718,14 @@ static int cx231xx_audio_init(struct cx231xx *dev)
713718
}
714719

715720
for (i = 0; i < adev->num_alt; i++) {
716-
u16 tmp =
717-
le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.
721+
u16 tmp;
722+
723+
if (uif->altsetting[i].desc.bNumEndpoints < isoc_pipe + 1) {
724+
err = -ENODEV;
725+
goto err_free_pkt_size;
726+
}
727+
728+
tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.
718729
wMaxPacketSize);
719730
adev->alt_max_pkt_size[i] =
720731
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
@@ -725,6 +736,8 @@ static int cx231xx_audio_init(struct cx231xx *dev)
725736

726737
return 0;
727738

739+
err_free_pkt_size:
740+
kfree(adev->alt_max_pkt_size);
728741
err_free_card:
729742
snd_card_free(card);
730743

0 commit comments

Comments
 (0)