diff options
author | Jason Gerecke <killertofu@gmail.com> | 2017-04-25 14:29:56 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2017-05-05 08:50:52 -0400 |
commit | 2ac97f0f6654da14312d125005c77a6010e0ea38 (patch) | |
tree | 5377d65daa737c5bc52abef64687538ae58a54ff | |
parent | 7af4c727c7b6104f94f2ffc3d0899e75a9cc1e55 (diff) |
HID: wacom: Have wacom_tpc_irq guard against possible NULL dereference
The following Smatch complaint was generated in response to commit
2a6cdbd ("HID: wacom: Introduce new 'touch_input' device"):
drivers/hid/wacom_wac.c:1586 wacom_tpc_irq()
error: we previously assumed 'wacom->touch_input' could be null (see line 1577)
The 'touch_input' and 'pen_input' variables point to the 'struct input_dev'
used for relaying touch and pen events to userspace, respectively. If a
device does not have a touch interface or pen interface, the associated
input variable is NULL. The 'wacom_tpc_irq()' function is responsible for
forwarding input reports to a more-specific IRQ handler function. An
unknown report could theoretically be mistaken as e.g. a touch report
on a device which does not have a touch interface. This can be prevented
by only calling the pen/touch functions are called when the pen/touch
pointers are valid.
Fixes: 2a6cdbd ("HID: wacom: Introduce new 'touch_input' device")
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/wacom_wac.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 4b225fb19a16..e274c9dc32f3 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
@@ -1571,37 +1571,38 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | |||
1571 | { | 1571 | { |
1572 | unsigned char *data = wacom->data; | 1572 | unsigned char *data = wacom->data; |
1573 | 1573 | ||
1574 | if (wacom->pen_input) | 1574 | if (wacom->pen_input) { |
1575 | dev_dbg(wacom->pen_input->dev.parent, | 1575 | dev_dbg(wacom->pen_input->dev.parent, |
1576 | "%s: received report #%d\n", __func__, data[0]); | 1576 | "%s: received report #%d\n", __func__, data[0]); |
1577 | else if (wacom->touch_input) | 1577 | |
1578 | if (len == WACOM_PKGLEN_PENABLED || | ||
1579 | data[0] == WACOM_REPORT_PENABLED) | ||
1580 | return wacom_tpc_pen(wacom); | ||
1581 | } | ||
1582 | else if (wacom->touch_input) { | ||
1578 | dev_dbg(wacom->touch_input->dev.parent, | 1583 | dev_dbg(wacom->touch_input->dev.parent, |
1579 | "%s: received report #%d\n", __func__, data[0]); | 1584 | "%s: received report #%d\n", __func__, data[0]); |
1580 | 1585 | ||
1581 | switch (len) { | 1586 | switch (len) { |
1582 | case WACOM_PKGLEN_TPC1FG: | 1587 | case WACOM_PKGLEN_TPC1FG: |
1583 | return wacom_tpc_single_touch(wacom, len); | 1588 | return wacom_tpc_single_touch(wacom, len); |
1584 | 1589 | ||
1585 | case WACOM_PKGLEN_TPC2FG: | 1590 | case WACOM_PKGLEN_TPC2FG: |
1586 | return wacom_tpc_mt_touch(wacom); | 1591 | return wacom_tpc_mt_touch(wacom); |
1587 | 1592 | ||
1588 | case WACOM_PKGLEN_PENABLED: | 1593 | default: |
1589 | return wacom_tpc_pen(wacom); | 1594 | switch (data[0]) { |
1595 | case WACOM_REPORT_TPC1FG: | ||
1596 | case WACOM_REPORT_TPCHID: | ||
1597 | case WACOM_REPORT_TPCST: | ||
1598 | case WACOM_REPORT_TPC1FGE: | ||
1599 | return wacom_tpc_single_touch(wacom, len); | ||
1590 | 1600 | ||
1591 | default: | 1601 | case WACOM_REPORT_TPCMT: |
1592 | switch (data[0]) { | 1602 | case WACOM_REPORT_TPCMT2: |
1593 | case WACOM_REPORT_TPC1FG: | 1603 | return wacom_mt_touch(wacom); |
1594 | case WACOM_REPORT_TPCHID: | ||
1595 | case WACOM_REPORT_TPCST: | ||
1596 | case WACOM_REPORT_TPC1FGE: | ||
1597 | return wacom_tpc_single_touch(wacom, len); | ||
1598 | |||
1599 | case WACOM_REPORT_TPCMT: | ||
1600 | case WACOM_REPORT_TPCMT2: | ||
1601 | return wacom_mt_touch(wacom); | ||
1602 | 1604 | ||
1603 | case WACOM_REPORT_PENABLED: | 1605 | } |
1604 | return wacom_tpc_pen(wacom); | ||
1605 | } | 1606 | } |
1606 | } | 1607 | } |
1607 | 1608 | ||