diff options
author | Stefan Achatz <erazor_de@users.sourceforge.net> | 2011-06-12 04:02:44 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-06-13 07:06:23 -0400 |
commit | 901e64dbdb5998b9248c372a401c921bbdf662f6 (patch) | |
tree | 439c7685adb52e2b97b968ee6535da29a8434915 | |
parent | 1edd5b42a6631b1b1f147e9018e309bde8d96a05 (diff) |
HID: roccat: fix NULL pointer dereference, add range checks
On rare occassions raw events can be triggered before drvdata gets set up
which leads to NULL pointer dereferences. This was only observed with pyra on
2.6.39, but is fixed for all devices now to play it save.
kovaplus returned wrong actual values when profile change was initiated from host.
Added range checks for setting actual profile on all devices.
Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/hid-roccat-arvo.c | 5 | ||||
-rw-r--r-- | drivers/hid/hid-roccat-kone.c | 3 | ||||
-rw-r--r-- | drivers/hid/hid-roccat-koneplus.c | 8 | ||||
-rw-r--r-- | drivers/hid/hid-roccat-kovaplus.c | 5 | ||||
-rw-r--r-- | drivers/hid/hid-roccat-pyra.c | 3 |
5 files changed, 21 insertions, 3 deletions
diff --git a/drivers/hid/hid-roccat-arvo.c b/drivers/hid/hid-roccat-arvo.c index 610536606195..093bfad00b02 100644 --- a/drivers/hid/hid-roccat-arvo.c +++ b/drivers/hid/hid-roccat-arvo.c | |||
@@ -163,6 +163,9 @@ static ssize_t arvo_sysfs_set_actual_profile(struct device *dev, | |||
163 | if (retval) | 163 | if (retval) |
164 | return retval; | 164 | return retval; |
165 | 165 | ||
166 | if (profile < 1 || profile > 5) | ||
167 | return -EINVAL; | ||
168 | |||
166 | temp_buf.command = ARVO_COMMAND_ACTUAL_PROFILE; | 169 | temp_buf.command = ARVO_COMMAND_ACTUAL_PROFILE; |
167 | temp_buf.actual_profile = profile; | 170 | temp_buf.actual_profile = profile; |
168 | 171 | ||
@@ -399,7 +402,7 @@ static int arvo_raw_event(struct hid_device *hdev, | |||
399 | if (size != 3) | 402 | if (size != 3) |
400 | return 0; | 403 | return 0; |
401 | 404 | ||
402 | if (arvo->roccat_claimed) | 405 | if (arvo && arvo->roccat_claimed) |
403 | arvo_report_to_chrdev(arvo, data); | 406 | arvo_report_to_chrdev(arvo, data); |
404 | 407 | ||
405 | return 0; | 408 | return 0; |
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index 7e29778fe7ab..2b8f3a31ffb3 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c | |||
@@ -832,6 +832,9 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report, | |||
832 | if (size != sizeof(struct kone_mouse_event)) | 832 | if (size != sizeof(struct kone_mouse_event)) |
833 | return 0; | 833 | return 0; |
834 | 834 | ||
835 | if (kone == NULL) | ||
836 | return 0; | ||
837 | |||
835 | /* | 838 | /* |
836 | * Firmware 1.38 introduced new behaviour for tilt and special buttons. | 839 | * Firmware 1.38 introduced new behaviour for tilt and special buttons. |
837 | * Pressed button is reported in each movement event. | 840 | * Pressed button is reported in each movement event. |
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 33ecad50395b..59e47770fa10 100644 --- a/drivers/hid/hid-roccat-koneplus.c +++ b/drivers/hid/hid-roccat-koneplus.c | |||
@@ -431,6 +431,9 @@ static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev, | |||
431 | if (retval) | 431 | if (retval) |
432 | return retval; | 432 | return retval; |
433 | 433 | ||
434 | if (profile > 4) | ||
435 | return -EINVAL; | ||
436 | |||
434 | mutex_lock(&koneplus->koneplus_lock); | 437 | mutex_lock(&koneplus->koneplus_lock); |
435 | 438 | ||
436 | retval = koneplus_set_actual_profile(usb_dev, profile); | 439 | retval = koneplus_set_actual_profile(usb_dev, profile); |
@@ -439,7 +442,7 @@ static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev, | |||
439 | return retval; | 442 | return retval; |
440 | } | 443 | } |
441 | 444 | ||
442 | koneplus->actual_profile = profile; | 445 | koneplus_profile_activated(koneplus, profile); |
443 | 446 | ||
444 | roccat_report.type = KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE; | 447 | roccat_report.type = KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE; |
445 | roccat_report.data1 = profile + 1; | 448 | roccat_report.data1 = profile + 1; |
@@ -751,6 +754,9 @@ static int koneplus_raw_event(struct hid_device *hdev, | |||
751 | != USB_INTERFACE_PROTOCOL_MOUSE) | 754 | != USB_INTERFACE_PROTOCOL_MOUSE) |
752 | return 0; | 755 | return 0; |
753 | 756 | ||
757 | if (koneplus == NULL) | ||
758 | return 0; | ||
759 | |||
754 | koneplus_keep_values_up_to_date(koneplus, data); | 760 | koneplus_keep_values_up_to_date(koneplus, data); |
755 | 761 | ||
756 | if (koneplus->roccat_claimed) | 762 | if (koneplus->roccat_claimed) |
diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c index 212e7921e942..1f8336e3f584 100644 --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c | |||
@@ -337,7 +337,7 @@ static ssize_t kovaplus_sysfs_set_actual_profile(struct device *dev, | |||
337 | 337 | ||
338 | mutex_lock(&kovaplus->kovaplus_lock); | 338 | mutex_lock(&kovaplus->kovaplus_lock); |
339 | retval = kovaplus_set_actual_profile(usb_dev, profile); | 339 | retval = kovaplus_set_actual_profile(usb_dev, profile); |
340 | kovaplus->actual_profile = profile; | 340 | kovaplus_profile_activated(kovaplus, profile); |
341 | mutex_unlock(&kovaplus->kovaplus_lock); | 341 | mutex_unlock(&kovaplus->kovaplus_lock); |
342 | if (retval) | 342 | if (retval) |
343 | return retval; | 343 | return retval; |
@@ -662,6 +662,9 @@ static int kovaplus_raw_event(struct hid_device *hdev, | |||
662 | != USB_INTERFACE_PROTOCOL_MOUSE) | 662 | != USB_INTERFACE_PROTOCOL_MOUSE) |
663 | return 0; | 663 | return 0; |
664 | 664 | ||
665 | if (kovaplus == NULL) | ||
666 | return 0; | ||
667 | |||
665 | kovaplus_keep_values_up_to_date(kovaplus, data); | 668 | kovaplus_keep_values_up_to_date(kovaplus, data); |
666 | 669 | ||
667 | if (kovaplus->roccat_claimed) | 670 | if (kovaplus->roccat_claimed) |
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 75a092e0d1d8..8140776bd8c5 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
@@ -637,6 +637,9 @@ static int pyra_raw_event(struct hid_device *hdev, struct hid_report *report, | |||
637 | != USB_INTERFACE_PROTOCOL_MOUSE) | 637 | != USB_INTERFACE_PROTOCOL_MOUSE) |
638 | return 0; | 638 | return 0; |
639 | 639 | ||
640 | if (pyra == NULL) | ||
641 | return 0; | ||
642 | |||
640 | pyra_keep_values_up_to_date(pyra, data); | 643 | pyra_keep_values_up_to_date(pyra, data); |
641 | 644 | ||
642 | if (pyra->roccat_claimed) | 645 | if (pyra->roccat_claimed) |