aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2017-01-17 18:38:58 -0500
committerJiri Kosina <jkosina@suse.cz>2017-01-19 08:19:25 -0500
commita9ce7856cad1bf43de5c43888e4076e77371d51b (patch)
tree458b84a40d30ed494712d9772c07c91240544c75
parent7a546af50eb78ab99840903083231eb635c8a566 (diff)
HID: wacom: Fix sibling detection regression
Commit 345857b ("HID: wacom: generic: Add support for sensor offsets") included a change to the operation and location of the call to 'wacom_add_shared_data' in 'wacom_parse_and_register'. The modifications included moving it higher up so that it would occur before the call to 'wacom_retrieve_hid_descriptor'. This was done to prevent a crash that would have occured when the report containing tablet offsets was fed into the driver with 'wacom_hid_report_raw_event' (specifically: the various 'wacom_wac_*_report' functions were written with the assumption that they would only be called once tablet setup had completed; 'wacom_wac_pen_report' in particular dereferences 'shared' which wasn't yet allocated). Moving the call to 'wacom_add_shared_data' effectively prevented the crash but also broke the sibiling detection code which assumes that the HID descriptor has been read and the various device_type flags set. To fix this situation, we restore the original 'wacom_add_shared_data' operation and location and instead implement an alternative change that can also prevent the crash. Specifically, we notice that the report functions mentioned above expect to be called only for input reports. By adding a check, we can prevent feature reports (such as the offset report) from causing trouble. Fixes: 345857bb49 ("HID: wacom: generic: Add support for sensor offsets") Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Tested-by: Ping Cheng <pingc@wacom.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/wacom_sys.c16
-rw-r--r--drivers/hid/wacom_wac.c10
2 files changed, 18 insertions, 8 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index b9779bcbd140..8aeca038cc73 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -740,6 +740,11 @@ static int wacom_add_shared_data(struct hid_device *hdev)
740 return retval; 740 return retval;
741 } 741 }
742 742
743 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH)
744 wacom_wac->shared->touch = hdev;
745 else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN)
746 wacom_wac->shared->pen = hdev;
747
743out: 748out:
744 mutex_unlock(&wacom_udev_list_lock); 749 mutex_unlock(&wacom_udev_list_lock);
745 return retval; 750 return retval;
@@ -2036,10 +2041,6 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2036 if (error) 2041 if (error)
2037 goto fail; 2042 goto fail;
2038 2043
2039 error = wacom_add_shared_data(hdev);
2040 if (error)
2041 goto fail;
2042
2043 /* 2044 /*
2044 * Bamboo Pad has a generic hid handling for the Pen, and we switch it 2045 * Bamboo Pad has a generic hid handling for the Pen, and we switch it
2045 * into debug mode for the touch part. 2046 * into debug mode for the touch part.
@@ -2080,10 +2081,9 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2080 2081
2081 wacom_update_name(wacom, wireless ? " (WL)" : ""); 2082 wacom_update_name(wacom, wireless ? " (WL)" : "");
2082 2083
2083 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) 2084 error = wacom_add_shared_data(hdev);
2084 wacom_wac->shared->touch = hdev; 2085 if (error)
2085 else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN) 2086 goto fail;
2086 wacom_wac->shared->pen = hdev;
2087 2087
2088 if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) && 2088 if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) &&
2089 (features->quirks & WACOM_QUIRK_BATTERY)) { 2089 (features->quirks & WACOM_QUIRK_BATTERY)) {
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index b1a9a3ca6d56..0884dc9554fd 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2187,6 +2187,16 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2187 2187
2188 wacom_report_events(hdev, report); 2188 wacom_report_events(hdev, report);
2189 2189
2190 /*
2191 * Non-input reports may be sent prior to the device being
2192 * completely initialized. Since only their events need
2193 * to be processed, exit after 'wacom_report_events' has
2194 * been called to prevent potential crashes in the report-
2195 * processing functions.
2196 */
2197 if (report->type != HID_INPUT_REPORT)
2198 return;
2199
2190 if (WACOM_PAD_FIELD(field)) { 2200 if (WACOM_PAD_FIELD(field)) {
2191 wacom_wac_pad_battery_report(hdev, report); 2201 wacom_wac_pad_battery_report(hdev, report);
2192 if (wacom->wacom_wac.pad_input) 2202 if (wacom->wacom_wac.pad_input)