hidinput_hid_event is doing a wrong check before a
division:
if (usage->hat_max != usage->hat_min) {
should be:
if ( (usage->hat_max - usage->hat_min + 1) != 0) {
because after that, there is:
value = (value - usage->hat_min) * 8 / (usage->hat_max
- usage->hat_min + 1) + 1;
This was causing divide by zero oops with my logitech
rumblepad usb joystick
Logged In: YES
user_id=542443
seems that the != check is also needed. With this patch the
Logitech rumblepad joystick that generated kernel panics is
well and alive:
--- drivers/usb/hid-input.c 2002-11-02 21:53:03.000000000 +0100
+++ ../linux-2.4.20-pre11/drivers/usb/hid-input.c 2002-11-03
00:48:13.000000000 +0100
@@ -303,7 +303,7 @@
struct input_dev *input = &hid->input;
int *quirks = &hid->quirks;
- if (usage->hat_min != usage->hat_max) {
+ if ( ((usage->hat_max - usage->hat_min + 1) != 0) &&
(usage->hat_max != usage->hat_min)) {
value = (value - usage->hat_min) * 8 / (usage->hat_max -
usage->hat_min + 1) + 1;
if (value < 0 || value > 8) value = 0;
input_event(input, usage->type, usage->code ,
hid_hat_to_axis[value].x);
Logged In: YES
user_id=542443
seems that the != check is also needed. With this patch the
Logitech rumblepad joystick that generated kernel panics is
well and alive:
--- drivers/usb/hid-input.c 2002-11-02 21:53:03.000000000 +0100
+++ ../linux-2.4.20-pre11/drivers/usb/hid-input.c 2002-11-03
00:48:13.000000000 +0100
@@ -303,7 +303,7 @@
struct input_dev *input = &hid->input;
int *quirks = &hid->quirks;
- if (usage->hat_min != usage->hat_max) {
+ if ( ((usage->hat_max - usage->hat_min + 1) != 0) &&
(usage->hat_max != usage->hat_min)) {
value = (value - usage->hat_min) * 8 / (usage->hat_max -
usage->hat_min + 1) + 1;
if (value < 0 || value > 8) value = 0;
input_event(input, usage->type, usage->code ,
hid_hat_to_axis[value].x);