diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2015-01-09 15:48:58 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-01-11 18:57:04 -0500 |
commit | 34412ba28232e8b3b4955a4bbe53c9df4c7b2d1a (patch) | |
tree | f2a0a46f6d5a1f10e3d9c93abaac83e0ce555743 /drivers/input/mouse | |
parent | dfba8600024abb09dbabfcd9d3c887848f4b154c (diff) |
Input: alps - add sanity checks for non DualPoint devices
Make sure that driver does not process bogus packets as trackstick data
when there is no trackstick present and emit warnings in dmesg so potential
issues with trackstick handling will be visible for debugging.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r-- | drivers/input/mouse/alps.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 4d7c4ccdaa8a..dd2fd397466a 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) | |||
475 | struct input_dev *dev = priv->dev2; | 475 | struct input_dev *dev = priv->dev2; |
476 | int x, y, z, left, right, middle; | 476 | int x, y, z, left, right, middle; |
477 | 477 | ||
478 | /* It should be a DualPoint when received trackstick packet */ | ||
479 | if (!(priv->flags & ALPS_DUALPOINT)) { | ||
480 | psmouse_warn(psmouse, | ||
481 | "Rejected trackstick packet from non DualPoint device"); | ||
482 | return; | ||
483 | } | ||
484 | |||
478 | /* Sanity check packet */ | 485 | /* Sanity check packet */ |
479 | if (!(packet[0] & 0x40)) { | 486 | if (!(packet[0] & 0x40)) { |
480 | psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n"); | 487 | psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n"); |
@@ -699,7 +706,8 @@ static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse) | |||
699 | 706 | ||
700 | alps_report_semi_mt_data(psmouse, fingers); | 707 | alps_report_semi_mt_data(psmouse, fingers); |
701 | 708 | ||
702 | if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) { | 709 | if ((priv->flags & ALPS_DUALPOINT) && |
710 | !(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) { | ||
703 | input_report_key(dev2, BTN_LEFT, f->ts_left); | 711 | input_report_key(dev2, BTN_LEFT, f->ts_left); |
704 | input_report_key(dev2, BTN_RIGHT, f->ts_right); | 712 | input_report_key(dev2, BTN_RIGHT, f->ts_right); |
705 | input_report_key(dev2, BTN_MIDDLE, f->ts_middle); | 713 | input_report_key(dev2, BTN_MIDDLE, f->ts_middle); |
@@ -743,8 +751,11 @@ static void alps_process_packet_v6(struct psmouse *psmouse) | |||
743 | */ | 751 | */ |
744 | if (packet[5] == 0x7F) { | 752 | if (packet[5] == 0x7F) { |
745 | /* It should be a DualPoint when received Trackpoint packet */ | 753 | /* It should be a DualPoint when received Trackpoint packet */ |
746 | if (!(priv->flags & ALPS_DUALPOINT)) | 754 | if (!(priv->flags & ALPS_DUALPOINT)) { |
755 | psmouse_warn(psmouse, | ||
756 | "Rejected trackstick packet from non DualPoint device"); | ||
747 | return; | 757 | return; |
758 | } | ||
748 | 759 | ||
749 | /* Trackpoint packet */ | 760 | /* Trackpoint packet */ |
750 | x = packet[1] | ((packet[3] & 0x20) << 2); | 761 | x = packet[1] | ((packet[3] & 0x20) << 2); |
@@ -1026,6 +1037,13 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse) | |||
1026 | struct input_dev *dev2 = priv->dev2; | 1037 | struct input_dev *dev2 = priv->dev2; |
1027 | int x, y, z, left, right, middle; | 1038 | int x, y, z, left, right, middle; |
1028 | 1039 | ||
1040 | /* It should be a DualPoint when received trackstick packet */ | ||
1041 | if (!(priv->flags & ALPS_DUALPOINT)) { | ||
1042 | psmouse_warn(psmouse, | ||
1043 | "Rejected trackstick packet from non DualPoint device"); | ||
1044 | return; | ||
1045 | } | ||
1046 | |||
1029 | /* | 1047 | /* |
1030 | * b7 b6 b5 b4 b3 b2 b1 b0 | 1048 | * b7 b6 b5 b4 b3 b2 b1 b0 |
1031 | * Byte0 0 1 0 0 1 0 0 0 | 1049 | * Byte0 0 1 0 0 1 0 0 0 |