From patchwork Mon Jul 11 17:59:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 9223909 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BD6E60572 for ; Mon, 11 Jul 2016 18:00:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1730327D76 for ; Mon, 11 Jul 2016 18:00:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08A9B27E22; Mon, 11 Jul 2016 18:00:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 826A527D76 for ; Mon, 11 Jul 2016 18:00:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751191AbcGKR77 (ORCPT ); Mon, 11 Jul 2016 13:59:59 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:36242 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbcGKR76 (ORCPT ); Mon, 11 Jul 2016 13:59:58 -0400 Received: by mail-pa0-f68.google.com with SMTP id ib6so13165730pad.3 for ; Mon, 11 Jul 2016 10:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=7Omhxv5sKQOc0ETGkmVKomC6P4L0qeQTR+zMDWuhzC4=; b=qrGPittvQxXMUQT1mJ+48sOdjQXTuMOgNatNeFKxGtYkZWwr3hyNgUrwLmWQS9wIl2 ccge+uP/tpedr0KWQ+a61pEW4zryQyR1gfTmq9HgB0TJYITen8GTzfSWniGrw5+xKmNm ypmN5UrV55avdRdV4lJiFdsjKVqdAStj4PRvqWfvr31ed+J9SMv9UYjDgcfP/7zZOQOh tSjiJVN9YXLxtkPkY5WIcpgKSEMLHATCHDip59rIdwGN+KEgbWq17RJxONUc2hMB2XOj mfrJ6mJCWkFVjNMl1wUJWX6fDnXCNXBo3hLWplh9jwmhgqPHXFg2T2FiZS/+QY3AALGO 88Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7Omhxv5sKQOc0ETGkmVKomC6P4L0qeQTR+zMDWuhzC4=; b=mONstD1PuEWXsC/pIPwwL8098a8zx9tbDkIaHOk4Rfx1txKtFbLVenqdO5EAeMOcjz a+eQTeQByUdrDtFp+sTE4wSS8LewFMjM//pUgbkIsBs0VGmUuxyEoS3XzT70m8td9/29 pBYYCBc2Uu5LZ0RQbhtIKezVDckXTsf8RQqPQtiWm5dm5PRNW8PnQJ2Et1cwbPUv980n N9qSEnTmLMPVRID3B0+TiY41NvitHPS14XgiPiQgQArQPxTc+oI+I17hidIHqhjwou0J oKeAIIov5YF6XkWXfTQpw0XH/SlIpA1QqAal/FF4mS9fySeAoZP1PdlqHJGJzg0vMgjH pGIA== X-Gm-Message-State: ALyK8tJkDv5OLOuvmAY1eQgTFIBNGxPta6YueNcLgU2/xJfZ9yN4R4xy5KYXwjjdimSoQQ== X-Received: by 10.66.173.38 with SMTP id bh6mr37616910pac.116.1468259997953; Mon, 11 Jul 2016 10:59:57 -0700 (PDT) Received: from wtc005007.corp.onewacom.com (71-34-80-44.ptld.qwest.net. [71.34.80.44]) by smtp.gmail.com with ESMTPSA id 64sm5724067pfj.96.2016.07.11.10.59.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2016 10:59:56 -0700 (PDT) From: Jason Gerecke To: linux-input@vger.kernel.org Cc: Ping Cheng , Aaron Skomra , Benjamin Tissoires , Jason Gerecke , Jason Gerecke Subject: [PATCH] HID: wacom: Stop mapping touch usages after processing HID_DG_CONTACTCOUNT Date: Mon, 11 Jul 2016 10:59:50 -0700 Message-Id: <20160711175950.17121-1-killertofu@gmail.com> X-Mailer: git-send-email 2.9.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a touchscreen contains both multitouch and single-touch reports in its descriptor in that order, the driver may overwrite information it saved about the format of the multitouch report. This can cause the report processing code to get tripped up and send an incorrect event stream to userspace. In particular, this can cause last_slot_field to be overwritten with the result that the driver prematurely assumes it has finished processing a slot and sending the ABS_MT_SLOT event at the wrong point in time, associating events for the current contact with the following contact instead. To prevent this from occuring, we stop mapping usages after having seen HID_DG_CONTACTCOUNT. This usage is only present in multitouch reports, so the format of any following single-touch reports will have no effect. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index fcf2264..e499cdb 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1560,6 +1560,11 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, struct input_dev *input = wacom_wac->touch_input; unsigned touch_max = wacom_wac->features.touch_max; + /* stop processing after the first multitouch report */ + if (wacom_wac->hid_data.cc_report && + wacom_wac->hid_data.cc_report != field->report->id) + return; + switch (usage->hid) { case HID_GD_X: features->last_slot_field = usage->hid;