Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10797092imu; Thu, 6 Dec 2018 06:59:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/UrTqU+mCoDaf84xxTFETD75eZVojTcEePDgWD0iyDNOkMuje9T0S9z/o4H0T09Xs0/basC X-Received: by 2002:a62:4714:: with SMTP id u20mr28493307pfa.144.1544108372080; Thu, 06 Dec 2018 06:59:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544108372; cv=none; d=google.com; s=arc-20160816; b=iBp5/o9d9g6i8wBWmqkuvqglyLc70v9QFCa+3i9ual1D0SyIvX+Fl47SV13NOB4Nac /CGrlHnIC3wFjJUKSHDwNCcU3f4vboTj5Bs9d8upgfz8Atl9ArI/jmY45xHNlWmM/h23 UBSHYfZcOA97u3VNncTMAcFFIsrBWDu2boazmBYcrtBCvsE8LK8WcgxdbsFipBeoN5Th NWx9EyjVrJhNFRdPsZBf1BmQgkRpOwKcJUkuyLJRRGa544cJUmBN2Vlh5n15Niji1J4v /lb5XgQlwxoVXJus8yYiYx/Hmx6nGwiJv5qWuLqVDN+oWXnhZ0uGvyRaI0NEWtlM2FAq Qoww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oiYlHRgvVn3msVVbjw7wVeFfOjmbmXoXFUsD/ppDSgY=; b=o6a/XG5SNZ5NuBxR5xzGrIFSzSoP8uth4hk/iatpF7qM8tSrh07MDwiqFOZB7Z45TK PP76v43QjjLJeIQ/U9y4Nn5gcpR22KQCW9z6Uejkg8q0h9dccJdNGhDLKC6O9X2F8dkh 6TbpUhJMxSTllhqS5D/HJbw2vwoEHJbV7TxcGbpvlPqFKlynSXyKNe0y+GVCSPSW4mDd UBPCIPjuq0SLXKS9ub7qKd5YppbB0blEAnatZLvQTD6vFPIcNRRf32gs79966efhwybu zOx2hIS7nll0UPgqYErkoDy5jjuVSPWcWb8XOLDbggGWqePq/ETlI6b1RQiLhfWOCtP3 n+1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2e5VPj2q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si419641pgj.60.2018.12.06.06.59.16; Thu, 06 Dec 2018 06:59:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2e5VPj2q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726301AbeLFO5V (ORCPT + 99 others); Thu, 6 Dec 2018 09:57:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:47214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbeLFOmt (ORCPT ); Thu, 6 Dec 2018 09:42:49 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 66D912146D; Thu, 6 Dec 2018 14:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107368; bh=zOT8TJ0004G71497yRmGTanAeEP4uGlKgcAmn3SChto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2e5VPj2q7IYks3TTZ9CdcAQ9k22fliaAxmNyYv3+IXBFdNSFa7miLDLG4xKIRrPAc CZdN6r1eVxlR/bmtO5fvUWjmavvXGZKCRQJ58DhM7bdYy9KDhAqpxJ+Bjeh5ywBOWj /i3TezGvM0A77o3CO+WR/cXr7TCFuDKLIrpJ4tjo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Norris , Heiko Stuebner , Dmitry Torokhov Subject: [PATCH 4.14 36/55] Input: cros_ec_keyb - fix button/switch capability reports Date: Thu, 6 Dec 2018 15:39:10 +0100 Message-Id: <20181206143003.649092938@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143001.749982936@linuxfoundation.org> References: <20181206143001.749982936@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brian Norris commit ac5722c1643a2fb75224c79b578214956d34f989 upstream. The cros_ec_keyb_bs array lists buttons and switches together, expecting that its users will match the appropriate type and bit fields. But cros_ec_keyb_register_bs() only checks the 'bit' field, which causes misreported input capabilities in some cases. For example, tablets (e.g., Scarlet -- a.k.a. Acer Chromebook Tab 10) were reporting a SW_LID capability, because EC_MKBP_POWER_BUTTON and EC_MKBP_LID_OPEN happen to share the same bit. (This has comedic effect on a tablet, in which a power-management daemon then thinks this "lid" is closed, and so puts the system to sleep as soon as it boots!) To fix this, check both the 'ev_type' and 'bit' fields before reporting the capability. Tested with a lid (Kevin / Samsung Chromebook Plus) and without a lid (Scarlet / Acer Chromebook Tab 10). This error got introduced when porting the feature from the downstream Chromium OS kernel to be upstreamed. Fixes: cdd7950e7aa4 ("input: cros_ec_keyb: Add non-matrix buttons and switches") Cc: Signed-off-by: Brian Norris Reviewed-by: Heiko Stuebner Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/keyboard/cros_ec_keyb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -506,7 +506,8 @@ static int cros_ec_keyb_register_bs(stru for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) { const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i]; - if (buttons & BIT(map->bit)) + if ((map->ev_type == EV_KEY && (buttons & BIT(map->bit))) || + (map->ev_type == EV_SW && (switches & BIT(map->bit)))) input_set_capability(idev, map->ev_type, map->code); }