Skip to content

Commit

Permalink
HID: wacom: generic: Send data only when the interface is defined
Browse files Browse the repository at this point in the history
Sometime valid events may not be supported by the driver yet. Make
sure we don't process them when the code is not ready.

This fix prevents a kernel panic due to unsupported HID events.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-By: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Ping Cheng authored and Jiri Kosina committed Dec 9, 2016
1 parent 354a329 commit 6f46cf9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/hid/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2109,11 +2109,11 @@ void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
if (wacom->wacom_wac.features.type != HID_GENERIC)
return;

if (WACOM_PAD_FIELD(field))
if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
wacom_wac_pad_event(hdev, field, usage, value);
else if (WACOM_PEN_FIELD(field))
else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
wacom_wac_pen_event(hdev, field, usage, value);
else if (WACOM_FINGER_FIELD(field))
else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
wacom_wac_finger_event(hdev, field, usage, value);
}

Expand Down Expand Up @@ -2145,20 +2145,20 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
if (wacom_wac->features.type != HID_GENERIC)
return;

if (WACOM_PAD_FIELD(field))
if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
wacom_wac_pad_pre_report(hdev, report);
else if (WACOM_PEN_FIELD(field))
else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
wacom_wac_pen_pre_report(hdev, report);
else if (WACOM_FINGER_FIELD(field))
else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
wacom_wac_finger_pre_report(hdev, report);

wacom_report_events(hdev, report);

if (WACOM_PAD_FIELD(field))
if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
return wacom_wac_pad_report(hdev, report);
else if (WACOM_PEN_FIELD(field))
else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
return wacom_wac_pen_report(hdev, report);
else if (WACOM_FINGER_FIELD(field))
else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
return wacom_wac_finger_report(hdev, report);
}

Expand Down

0 comments on commit 6f46cf9

Please sign in to comment.