linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yiyuan GUO <yguoaz@gmail.com>
To: jikos@kernel.org
Cc: linux-input@vger.kernel.org, yguoaz@gmail.com,
	Yiyuan GUO <yguoaz@cse.ust.hk>
Subject: [PATCH] HID: wacom: check input_dev->absinfo in wacom_bpt3_touch_msg
Date: Mon, 17 May 2021 17:34:03 +0800	[thread overview]
Message-ID: <20210517093403.74276-1-yguoaz@cse.ust.hk> (raw)

The function wacom_bpt3_touch_msg calls input_abs_get_res(input,
ABS_MT_POSITION_X) to obtain x_res, which may equal to 0 if
input->absinfo is NULL. Since x_res is used as a divisor, this
may lead to divide by zero problem.

Signed-off-by: Yiyuan GUO <yguoaz@cse.ust.hk>
---
 drivers/hid/wacom_wac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 81d7d12bc..a5a6fb8bc 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2892,7 +2892,7 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
 	bool touch = data[1] & 0x80;
 	int slot = input_mt_get_slot_by_key(input, data[0]);
 
-	if (slot < 0)
+	if (slot < 0 || !input->absinfo)
 		return;
 
 	touch = touch && report_touch_events(wacom);
-- 
2.25.1


             reply	other threads:[~2021-05-17  9:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  9:34 Yiyuan GUO [this message]
2021-05-26 10:50 ` [PATCH] HID: wacom: check input_dev->absinfo in wacom_bpt3_touch_msg Jiri Kosina
2021-05-28 14:19   ` Gerecke, Jason
2021-06-03  1:33     ` Dmitry Torokhov

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=20210517093403.74276-1-yguoaz@cse.ust.hk \
    --to=yguoaz@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=yguoaz@cse.ust.hk \
    /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).