linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	stable <stable@vger.kernel.org>,
	Xing Wei <weixing@hanwang.com.cn>, Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 5/7] Input: hanwang - fix NULL-deref at probe
Date: Mon, 13 Mar 2017 13:35:37 +0100	[thread overview]
Message-ID: <20170313123539.28103-6-johan@kernel.org> (raw)
In-Reply-To: <20170313123539.28103-1-johan@kernel.org>

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")
Cc: stable <stable@vger.kernel.org>	# 2.6.37
Cc: Xing Wei <weixing@hanwang.com.cn>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/input/tablet/hanwang.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/tablet/hanwang.c b/drivers/input/tablet/hanwang.c
index cd852059b99e..df4bea96d7ed 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) {
-- 
2.12.0


  parent reply	other threads:[~2017-03-13 12:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-13 12:35 [PATCH 0/7] Input: fix NULL-derefs at probe Johan Hovold
2017-03-13 12:35 ` [PATCH 1/7] Input: iforce - fix NULL-deref " Johan Hovold
     [not found] ` <20170313123539.28103-1-johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-03-13 12:35   ` [PATCH 2/7] Input: cm109 " Johan Hovold
2017-03-13 15:15   ` [PATCH 0/7] Input: fix NULL-derefs " Oliver Neukum
2017-03-13 15:45     ` Johan Hovold
2017-03-16 22:37       ` Dmitry Torokhov
2017-03-17 10:53         ` Johan Hovold
2017-03-17 21:03           ` Dmitry Torokhov
2017-03-18  9:13             ` Johan Hovold
2017-03-13 12:35 ` [PATCH 3/7] Input: ims-pcu - fix NULL-deref " Johan Hovold
2017-03-13 12:35 ` [PATCH 4/7] Input: yealink " Johan Hovold
2017-03-13 12:35 ` Johan Hovold [this message]
2017-03-13 12:35 ` [PATCH 6/7] Input: kbtab " Johan Hovold
2017-03-13 12:35 ` [PATCH 7/7] Input: sur40 " Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170313123539.28103-6-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=weixing@hanwang.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).