linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Yunkang Tang <yunkang.tang@cn.alps.com>,
	Vadim Klishko <vadim@cirque.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/7] input: alps: Add sanity checks for non DualPoint devices
Date: Sun, 11 Jan 2015 16:31:00 -0800	[thread overview]
Message-ID: <20150112003100.GC31862@dtor-ws> (raw)
In-Reply-To: <1415993906-13307-7-git-send-email-pali.rohar@gmail.com>

On Fri, Nov 14, 2014 at 08:38:25PM +0100, Pali Rohár wrote:
> This patch adds sanity checks and reject trackstick packets from ALPS devices
> which do not have trackstick present (those without ALPS_DUALPOINT flag).
> 
> Make sure that driver does not process some bogus packets as trackstick data
> when there is no trackstick packet. Patch also write warning do dmesg so
> possible problems with driver (e.g received invalid data) will be visible
> for debugging.
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>

Applied, thank you.

> ---
>  drivers/input/mouse/alps.c |   22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> index 2b7b74d..770bec5 100644
> --- a/drivers/input/mouse/alps.c
> +++ b/drivers/input/mouse/alps.c
> @@ -475,6 +475,13 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
>  	struct input_dev *dev = priv->dev2;
>  	int x, y, z, left, right, middle;
>  
> +	/* It should be a DualPoint when received trackstick packet */
> +	if (!(priv->flags & ALPS_DUALPOINT)) {
> +		psmouse_warn(psmouse,
> +			"Rejected trackstick packet from non DualPoint device");
> +		return;
> +	}
> +
>  	/* Sanity check packet */
>  	if (!(packet[0] & 0x40)) {
>  		psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n");
> @@ -699,7 +706,8 @@ static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse)
>  
>  	alps_report_semi_mt_data(psmouse, fingers);
>  
> -	if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) {
> +	if ((priv->flags & ALPS_DUALPOINT) &&
> +	    !(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) {
>  		input_report_key(dev2, BTN_LEFT, f->ts_left);
>  		input_report_key(dev2, BTN_RIGHT, f->ts_right);
>  		input_report_key(dev2, BTN_MIDDLE, f->ts_middle);
> @@ -743,8 +751,11 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
>  	 */
>  	if (packet[5] == 0x7F) {
>  		/* It should be a DualPoint when received Trackpoint packet */
> -		if (!(priv->flags & ALPS_DUALPOINT))
> +		if (!(priv->flags & ALPS_DUALPOINT)) {
> +			psmouse_warn(psmouse,
> +			"Rejected trackstick packet from non DualPoint device");
>  			return;
> +		}
>  
>  		/* Trackpoint packet */
>  		x = packet[1] | ((packet[3] & 0x20) << 2);
> @@ -962,6 +973,13 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
>  	struct input_dev *dev2 = priv->dev2;
>  	int x, y, z, left, right, middle;
>  
> +	/* It should be a DualPoint when received trackstick packet */
> +	if (!(priv->flags & ALPS_DUALPOINT)) {
> +		psmouse_warn(psmouse,
> +			"Rejected trackstick packet from non DualPoint device");
> +		return;
> +	}
> +
>  	/*
>  	 *        b7 b6 b5 b4 b3 b2 b1 b0
>  	 * Byte0   0  1  0  0  1  0  0  0
> -- 
> 1.7.9.5
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-01-12  0:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14 19:38 [PATCH 0/7] Fixes for ALPS trackstick Pali Rohár
2014-11-14 19:38 ` [PATCH 1/7] input: alps: Set correct name of psmouse device in alps_init() Pali Rohár
2014-12-16  5:02   ` Dmitry Torokhov
2014-12-16 11:58     ` Pali Rohár
2014-12-20  8:53       ` Pali Rohár
2014-12-24  7:48         ` Pali Rohár
2015-01-08 17:58           ` Pali Rohár
2014-11-14 19:38 ` [PATCH 2/7] input: alps: Move trackstick detection to alps_hw_init_* Pali Rohár
2014-11-14 19:38 ` [PATCH 3/7] input: alps: Move alps_dolphin_get_device_area into alps_hw_init_dolphin_v1 Pali Rohár
2014-11-14 19:38 ` [PATCH 4/7] input: alps: Use NULL instead dummy argument for alps_identify Pali Rohár
2014-11-14 19:38 ` [PATCH 5/7] input: alps: Fix name, product and version of dev2 input device Pali Rohár
2015-01-12  0:30   ` Dmitry Torokhov
2014-11-14 19:38 ` [PATCH 6/7] input: alps: Add sanity checks for non DualPoint devices Pali Rohár
2015-01-12  0:31   ` Dmitry Torokhov [this message]
2015-01-13  7:50     ` Pali Rohár
2014-11-14 19:38 ` [PATCH 7/7] input: alps: Do not report both trackstick and external PS/2 mouse data to one input device Pali Rohár
2014-11-14 20:59 ` [PATCH 0/7] Fixes for ALPS trackstick Dmitry Torokhov
2014-11-17  7:39   ` Pali Rohár
2014-11-19 23:29     ` Pali Rohár
2014-11-25 11:08       ` Pali Rohár
2014-11-27 18:08         ` Dmitry Torokhov
2014-12-03 10:59           ` Pali Rohár
2014-12-09 17:08 ` Pali Rohár

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=20150112003100.GC31862@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=vadim@cirque.com \
    --cc=yunkang.tang@cn.alps.com \
    /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).