Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp406843pxb; Wed, 3 Mar 2021 06:22:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUJaxFALLnAW0LHSfcquZjOT2so4dkwJlyNKt1IFmi5q1sMIigHE5OJD1b7+OHpRcWwKtH X-Received: by 2002:aa7:c0c7:: with SMTP id j7mr12980883edp.298.1614781360640; Wed, 03 Mar 2021 06:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614781360; cv=none; d=google.com; s=arc-20160816; b=Sq+TcmayjCimxC/gqNd/7jAjtmWTEYwTKzfuQ1/mkyQwzCI73B3mUIa4D32MTpejXk QfdZJGPILLj0zenHarcmhsKhf6EhvBKomFgoBy+TobaGMXTsmhsvxgkWbKIBL2ErtqYa qr9A6VLPrklzofCvgzpOSL2XereiOdrYflJi8mONAK/b3KrsSbhPNiRUZzlFw/R2S3Hy 0hI34ZnFbCbF9R/gaJznok+GCpUOBdwBv5VJwDCyieoebZLFVMeKVtf1Te0wvYcK2rWd qWJ68rSiKpgn6RAr2IHGwTdT9FY+Zxdb4KtywkbognkrK1KgWsW8I1D9EAPKTfmo5/qO 1seQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+JgEgwLbFWfvhdfVc1pQKed6frNgK/pE6q06Be4VhBA=; b=NB8DgQAthg4aPweX+ZqF05kkXfXuWj8ds/QNnrYbukX1RsEIB/4RGv08KHKlz/Rac5 jvbv/xiJgkO5QMn+qD4UDTlLq6yU50l2oIePBPTKzvtqkQ06bMfB9hyDnRq+ptgNJse7 Ye3xA0ISrREok8HBlomdL8arb0eQob4zk2CkjNahE7QLUtONmrJntkaPd75Tngh+xLjC y7PstKLAdw0rF2aPkOQPqKgfJAELhvGOZoMu+7Jw+f1s2i8/73HD1icKx6oFUmTzAECF +nXUIkuOeSo/zuh5C2XgPKb6hxVR/7pSAj3Bp1JgGZ3HIMCmdULB/U2z3wyo0TasyXeZ xWkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="R3BOZ/o2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w14si15486005ede.222.2021.03.03.06.21.42; Wed, 03 Mar 2021 06:22:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="R3BOZ/o2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243728AbhCAVNH (ORCPT + 99 others); Mon, 1 Mar 2021 16:13:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:52684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237864AbhCARNj (ORCPT ); Mon, 1 Mar 2021 12:13:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0D34564E54; Mon, 1 Mar 2021 16:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617040; bh=aLK6ffcBiRedT1F3NNJKUOGr5BbyA71bN8TWbZPxhCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3BOZ/o2cve0PWfOLui5BV6aZ1J3Fa/kF3OOQU8kmopDBeTXIuYQVu0VxFjBPMOkB cEv+XzGfcux5ryuj+aIuqHrfR7wpii/alyr2crZWhL2hPn93HB3lrlGFfcNMn+pV3R RnM6tFRLFVsY0HaEfvJtabdP7gEYaxOSgIfdxFo8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gerecke , Jiri Kosina Subject: [PATCH 4.19 181/247] HID: wacom: Ignore attempts to overwrite the touch_max value from HID Date: Mon, 1 Mar 2021 17:13:21 +0100 Message-Id: <20210301161040.520537632@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gerecke commit 88f38846bfb1a452a3d47e38aeab20a4ceb74294 upstream. The `wacom_feature_mapping` function is careful to only set the the touch_max value a single time, but this care does not extend to the `wacom_wac_finger_event` function. In particular, if a device sends multiple HID_DG_CONTACTMAX items in a single feature report, the driver will end up retaining the value of last item. The HID descriptor for the Cintiq Companion 2 does exactly this. It incorrectly sets a "Report Count" of 2, which will cause the driver to process two HID_DG_CONTACTCOUNT items. The first item has the actual count, while the second item should have been declared as a constant zero. The constant zero is the value the driver ends up using, however, since it is the last HID_DG_CONTACTCOUNT in the report. Report ID (16), Usage (Contact Count Maximum), ; Contact count maximum (55h, static value) Report Count (2), Logical Maximum (10), Feature (Variable), To address this, we add a check that the touch_max is not already set within the `wacom_wac_finger_event` function that processes the HID_DG_TOUCHMAX item. We emit a warning if the value is set and ignore the updated value. This could potentially cause problems if there is a tablet which has a similar issue but requires the last item to be used. This is unlikely, however, since it would have to have a different non-zero value for HID_DG_CONTACTMAX earlier in the same report, which makes no sense except in the case of a firmware bug. Note that cases where the HID_DG_CONTACTMAX items are in different reports is already handled (and similarly ignored) by `wacom_feature_mapping` as mentioned above. Link: https://github.com/linuxwacom/input-wacom/issues/223 Fixes: 184eccd40389 ("HID: wacom: generic: read HID_DG_CONTACTMAX from any feature report") Signed-off-by: Jason Gerecke CC: stable@vger.kernel.org Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/wacom_wac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2557,7 +2557,12 @@ static void wacom_wac_finger_event(struc wacom_wac->hid_data.tipswitch = value; break; case HID_DG_CONTACTMAX: - features->touch_max = value; + if (!features->touch_max) { + features->touch_max = value; + } else { + hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max " + "%d -> %d\n", __func__, features->touch_max, value); + } return; }