From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:46111 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753437AbdDJM7f (ORCPT ); Mon, 10 Apr 2017 08:59:35 -0400 From: Jiri Slaby To: stable@vger.kernel.org Cc: Johan Hovold , Dmitry Torokhov , Jiri Slaby Subject: [patch added to 3.12-stable] Input: cm109 - validate number of endpoints before using them Date: Mon, 10 Apr 2017 14:58:43 +0200 Message-Id: <20170410125930.26495-6-jslaby@suse.cz> In-Reply-To: <20170410125930.26495-1-jslaby@suse.cz> References: <20170410125930.26495-1-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org List-ID: From: Johan Hovold This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== 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 Signed-off-by: Dmitry Torokhov Signed-off-by: Jiri Slaby --- drivers/input/misc/cm109.c | 4 ++++ 1 file changed, 4 insertions(+) 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)) -- 2.12.2