]> git.baikalelectronics.ru Git - kernel.git/commit
media: xirlink_cit: add missing descriptor sanity checks
authorJohan Hovold <johan@kernel.org>
Fri, 3 Jan 2020 16:35:11 +0000 (17:35 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 12 Mar 2020 16:27:07 +0000 (17:27 +0100)
commit8858a192948685bdc9f6604539479c1333af36a4
tree4f46a1826995b11253b16c34df86fd64d902bc9c
parentf12637a93116563505f04be53ecdd3a9168e1443
media: xirlink_cit: add missing descriptor sanity checks

Make sure to check that we have two alternate settings and at least one
endpoint before accessing the second altsetting structure and
dereferencing the endpoint arrays.

This specifically avoids dereferencing NULL-pointers or corrupting
memory when a device does not have the expected descriptors.

Note that the sanity check in cit_get_packet_size() is not redundant as
the driver is mixing looking up altsettings by index and by number,
which may not coincide.

Fixes: 417c1fbbfd71 ("V4L/DVB: gspca_xirlink_cit: Add support for camera with a bcd version of 0.01")
Fixes: 5105b7a29c68 ("V4L/DVB: gspca_xirlink_cit: support bandwidth changing for devices with 1 alt setting")
Cc: stable <stable@vger.kernel.org> # 2.6.37
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>
drivers/media/usb/gspca/xirlink_cit.c