From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F03A5C43381 for ; Wed, 20 Feb 2019 22:06:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD7022089F for ; Wed, 20 Feb 2019 22:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727377AbfBTWG5 (ORCPT ); Wed, 20 Feb 2019 17:06:57 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49766 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbfBTWG5 (ORCPT ); Wed, 20 Feb 2019 17:06:57 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 77306264026 Subject: Re: [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c To: Nick Crews , bleung@chromium.org Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, dan.carpenter@oracle.com, dlaurie@chromium.org References: <20190220215826.44366-1-ncrews@chromium.org> From: Enric Balletbo i Serra Message-ID: Date: Wed, 20 Feb 2019 23:06:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190220215826.44366-1-ncrews@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nick, Thanks for the patch. On 20/2/19 22:58, Nick Crews wrote: > Before, in debugfs.c it was possible to supply only the message type, > and not supply any other arguments when sending raw commands. However, > this is never used by the EC, and it led to an underflow error. Now, > just don't allow too short of a command, we will never need > that anyways. > > Fixes: 46c7fd06f8c9 ("platform/chrome: wilco_ec: Add support for raw commands in debugfs") As this is -next material I'd like to squash the fix if you don't mind. -- Enric > Signed-off-by: Nick Crews > --- > drivers/platform/chrome/wilco_ec/debugfs.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c > index 46ff3b6c46c7..c090db2cd5be 100644 > --- a/drivers/platform/chrome/wilco_ec/debugfs.c > +++ b/drivers/platform/chrome/wilco_ec/debugfs.c > @@ -136,8 +136,8 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf, > ret = parse_hex_sentence(buf, kcount, request_data, TYPE_AND_DATA_SIZE); > if (ret < 0) > return ret; > - /* Need at least two bytes for message type */ > - if (ret < 2) > + /* Need at least two bytes for message type and one for command */ > + if (ret < 3) > return -EINVAL; > > /* Clear response data buffer */ > @@ -145,7 +145,7 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf, > > msg.type = request_data[0] << 8 | request_data[1]; > msg.flags = WILCO_EC_FLAG_RAW; > - msg.command = ret > 2 ? request_data[2] : 0; > + msg.command = request_data[2]; > msg.request_data = ret > 3 ? request_data + 3 : 0; > msg.request_size = ret - 3; > msg.response_data = debug_info->raw_data; >