Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp52797imm; Wed, 3 Oct 2018 11:44:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV62RFRv1OkGxxG9Up06V9sAm9JQMsRGITsblWCHCCPqkqg0MXAAECt7Dbao97+8b3ys7H9Yq X-Received: by 2002:a17:902:9047:: with SMTP id w7-v6mr2987097plz.291.1538592247814; Wed, 03 Oct 2018 11:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538592247; cv=none; d=google.com; s=arc-20160816; b=rt+nuoQBbNBrPULWaM3q/zi2JaD4iRa9yqfRT35N8CEX+Cum6OnVghHHux8c0ld+Jb l5S9aRwg7Vo8v9n65Le8hnUD+kDRbt4EyI5hWD8+R+l/8VnS4XRIoliapZ4+wHJWe0Hp DrKXauQrzllSpjeioHl/67wf+0+bmk2/u+82NPMz2B7VDwH//p1CK+iTWy0upaW9WPqF GY+zUpycm7iR5lvhOrAta6M0FKSvLNZAdJPUdk+ZtmzsvC8DhjqGHs2hkQTck9F+JL9B eYYya/WOmAypWdmwbDoGVPtCRCd0AdUP02EuO9bhiR+v0WPPA7tPGAolY/yM8WTJvVho 4oaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EcbDPM+YPlERGymPnPxHphlyyRAb3msvP6XFTGFN7Oc=; b=YZ1ed4K4Sr+9fTuVuLXV1YUgXDwTok5LXiNlqPBWIDavDdy2EQDTvlX1QMqf5A3JCq q9y6RLOx9A+tbRNeyqj/s4pXy/U61ev6Jo2N8HIILZnRysxUwriBmElROJUcuaTxOQ0h R6V/cPFWKJx1y5R58fkWLDcxO5r1oTT8W9evpil1vXoOTwna5MhTsuUg2wiohHHJEJR9 aCrprpJtG5hkKpMlyNcimCLIz5/fjzR+itp/tcBMws3vocIhaxFL8+gagWEluKCRpQmq VhjXJaYRKxENDScgRmWeCerjednpcGSAsBbFz2CIpMrgo36ec5iu6UsBUu/bW7HwwgTW hdVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=quExXl70; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14-v6si2158347pfi.184.2018.10.03.11.43.51; Wed, 03 Oct 2018 11:44:07 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=quExXl70; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbeJDBdL (ORCPT + 99 others); Wed, 3 Oct 2018 21:33:11 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:43347 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726941AbeJDBdL (ORCPT ); Wed, 3 Oct 2018 21:33:11 -0400 Received: by mail-lj1-f193.google.com with SMTP id r8-v6so6053654ljc.10 for ; Wed, 03 Oct 2018 11:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EcbDPM+YPlERGymPnPxHphlyyRAb3msvP6XFTGFN7Oc=; b=quExXl70PH5cXp8fV189KgS3Ht/+tX21UdOe74V6xq1vxCK8aAyB/O4mNMbPPbKoUC S44uJxhmIatWl+f7FWhBbsh8u/SHW3A+S85Ow/aHITknXk9NLpvY6uO6wUQPRggMsk7q ibvUJb3OBJIflmas01jSfj0rEuN8wx911PMg/V65LKD/+5a+UIf8G8NZhilcFoTgkgqs /Tcd30KqRlACvqQuX3hn37XXNv625t6J2mrupC/TnscnRvW71KWGNGQO/SuMDXj87iIu jDIhxtlbGNnUrt8zKX0fS2VylIH6DP26DKjjVJnDD2q3r+HTg6YNtEvjcwnGjGpuQdXJ qbwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EcbDPM+YPlERGymPnPxHphlyyRAb3msvP6XFTGFN7Oc=; b=F3jaCPP3/WZNACPMYQxgcEk0es2YabGZqo08r/jNcKVctfqCHOwQ7Ag1Jix1+viReW ikejQRhz7ZCAIP0A8bvt/+yz3dWEWAXdImC718N/Q7EZgDy/vchMewOFrdAVAy0kq+nj wfDy/bpNF6PVMusj9r0G07qQfRLWhLKEbJIq4bU+s8kS5lC7oiQ7/SDWfa6WWmly3rnx lWQQbIN1BarCM0018t0nrFSwATremyf23bn3mA3jTbFEZlx/dq+1TuktNcmeKtxj8cIR GIrPVCXdWhRRM/irAXRf5lq7AG5k1vhbhebUV5BTlL6Eqhf/pAsxZEQlTi3HYZi7QpOt Yn3w== X-Gm-Message-State: ABuFfojqE3+uD6nmdDygFwm0CK4XNE5CuBCI6IAvUL+s3ddDFEfExdBQ DRowlL0zrlZaXC1RYVqE1S2jpotYpQ== X-Received: by 2002:a2e:7809:: with SMTP id t9-v6mr1797007ljc.120.1538592214456; Wed, 03 Oct 2018 11:43:34 -0700 (PDT) Received: from localhost.localdomain ([2001:999:51:565d:44e6:f5ff:fe2f:8bf6]) by smtp.gmail.com with ESMTPSA id l3-v6sm497478lja.25.2018.10.03.11.43.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 11:43:32 -0700 (PDT) From: Emil Karlson To: Emil Renner Berthing , Neil Armstrong , Stefan Adolfsson , lee.jones@linaro.org, bleung@chromium.org, olof@lixom.net, Enric Balletbo i Serra , linux-kernel@vger.kernel.org Cc: Emil Karlson Subject: [PATCH v3] mfd: cros-ec: copy the whole event in get_next_event_xfer Date: Wed, 3 Oct 2018 21:43:18 +0300 Message-Id: <20181003184318.856-1-jekarlson@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <13bda116-5766-1340-81e1-48ca899ff41a@baylibre.com> References: <13bda116-5766-1340-81e1-48ca899ff41a@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 57e94c8b974db2d83c60e1139c89a70806abbea0 caused cros-ec keyboard events be truncated on many chromebooks so that Left and Right keys on Column 12 were always 0. Use ret as memcpy len to fix this. The old code was using ec_dev->event_size, which is the event payload/data size excluding event_type header, for the length of the memcpy operation. Use ret as memcpy length to avoid the off by one and copy the whole msg->data. Fixes: 57e94c8b974d ("mfd: cros-ec: Increase maximum mkbp event size") Acked-by: Enric Balletbo i Serra Tested-by: Emil Renner Berthing Signed-off-by: Emil Karlson --- Notes: Changes in v3 - Improve commit message. Changes in v2 - Fix the off by one in memcpy parameter rather than restoring the old behaviour for v0 messages. drivers/platform/chrome/cros_ec_proto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index 398393ab5df8..b6fd4838f60f 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -520,7 +520,7 @@ static int get_next_event_xfer(struct cros_ec_device *ec_dev, ret = cros_ec_cmd_xfer(ec_dev, msg); if (ret > 0) { ec_dev->event_size = ret - 1; - memcpy(&ec_dev->event_data, msg->data, ec_dev->event_size); + memcpy(&ec_dev->event_data, msg->data, ret); } return ret; -- 2.19.0