summaryrefslogtreecommitdiff
path: root/drivers/input/misc/cm109.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-16 11:35:12 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-30 09:35:15 +0200
commitc05490638ddfffa35d2fb03c1852f9013757a9e1 (patch)
tree735e6b20458295353a26f050e9af077a19269668 /drivers/input/misc/cm109.c
parente916f1d6188ef765303b4f74387d7e92d49a5be6 (diff)
Input: cm109 - validate number of endpoints before using them
commit ac2ee9ba953afe88f7a673e1c0c839227b1d7891 upstream. Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints. Fixes: c04148f915e5 ("Input: add driver for USB VoIP phones with CM109...") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/input/misc/cm109.c')
-rw-r--r--drivers/input/misc/cm109.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
index 9365535ba7f1..50a7faa504f7 100644
--- a/drivers/input/misc/cm109.c
+++ b/drivers/input/misc/cm109.c
@@ -675,6 +675,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
int error = -ENOMEM;
interface = intf->cur_altsetting;
+
+ if (interface->desc.bNumEndpoints < 1)
+ return -ENODEV;
+
endpoint = &interface->endpoint[0].desc;
if (!usb_endpoint_is_int_in(endpoint))