From: Johan Hovold Date: Thu, 16 Mar 2017 18:39:29 +0000 (-0700) Subject: Input: hanwang - validate number of endpoints before using them X-Git-Tag: v4.14-rc1~4^2~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba340d7b83703768ce566f53f857543359aa1b98;p=platform%2Fkernel%2Flinux-rpi.git Input: hanwang - validate number of endpoints before using them Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints. Fixes: bba5394ad3bd ("Input: add support for Hanwang tablets") Signed-off-by: Johan Hovold Cc: stable@vger.kernel.org # 2.6.37 Signed-off-by: Dmitry Torokhov --- diff --git a/drivers/input/tablet/hanwang.c b/drivers/input/tablet/hanwang.c index cd85205..df4bea9 100644 --- a/drivers/input/tablet/hanwang.c +++ b/drivers/input/tablet/hanwang.c @@ -340,6 +340,9 @@ static int hanwang_probe(struct usb_interface *intf, const struct usb_device_id int error; int i; + if (intf->cur_altsetting->desc.bNumEndpoints < 1) + return -ENODEV; + hanwang = kzalloc(sizeof(struct hanwang), GFP_KERNEL); input_dev = input_allocate_device(); if (!hanwang || !input_dev) {