Skip to content

Commit 9989123

Browse files
jhovoldmchehab
authored andcommitted
media: ov519: add missing endpoint sanity checks
Make sure to check that we have at least one endpoint before accessing the endpoint array to avoid dereferencing a NULL-pointer on stream start. Note that these sanity checks are not redundant as the driver is mixing looking up altsettings by index and by number, which need not coincide. Fixes: 1876bb9 ("V4L/DVB (12079): gspca_ov519: add support for the ov511 bridge") Fixes: b282d87 ("V4L/DVB (12080): gspca_ov519: Fix ov518+ with OV7620AE (Trust spacecam 320)") Cc: stable <stable@vger.kernel.org> # 2.6.31 Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 8ff3cf4 commit 9989123

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: drivers/media/usb/gspca/ov519.c

+10
Original file line numberDiff line numberDiff line change
@@ -3477,6 +3477,11 @@ static void ov511_mode_init_regs(struct sd *sd)
34773477
return;
34783478
}
34793479

3480+
if (alt->desc.bNumEndpoints < 1) {
3481+
sd->gspca_dev.usb_err = -ENODEV;
3482+
return;
3483+
}
3484+
34803485
packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
34813486
reg_w(sd, R51x_FIFO_PSIZE, packet_size >> 5);
34823487

@@ -3603,6 +3608,11 @@ static void ov518_mode_init_regs(struct sd *sd)
36033608
return;
36043609
}
36053610

3611+
if (alt->desc.bNumEndpoints < 1) {
3612+
sd->gspca_dev.usb_err = -ENODEV;
3613+
return;
3614+
}
3615+
36063616
packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
36073617
ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2);
36083618

0 commit comments

Comments
 (0)