Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2676806iof; Wed, 8 Jun 2022 09:42:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkCbDwlLxghqsr3fHUder37TxDJDagVUlBIIOZQtYq857/SwwcGvDEi4NmOqLI6O/7gCyP X-Received: by 2002:a63:6a49:0:b0:3fd:df6d:5ba3 with SMTP id f70-20020a636a49000000b003fddf6d5ba3mr11929464pgc.385.1654706544030; Wed, 08 Jun 2022 09:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654706544; cv=none; d=google.com; s=arc-20160816; b=WUPIRasXZr5YM/VzVJN6/hhT+0qp+/rOHhH3bXshfkY6TO6Eue28na6MvH6CDaDcx0 cSLDDlG5MCz6v5Za97SFVN6016ySrr/utWkQRuEl3a9J7PxEQkQbrGsjST9g8qpOfn+I MQD82DFufmK7O1UIh39FJjsXoSugF5505pTXF/pSaFO1C1OBWymjt3cp1W612xIImtSc taN0r67FLdb+k5Oeug419X/PrMqm0EzxfzmanCScAFPw9hlUGrzRKr9ALrR2koRpHS4A mDJxxd2p6cRUxR9DPEJX+lzGABwmiHN7Eom1QJfLVuBVIcar7XSoJ5DVGbu95aiAR4ci YdBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Tbbr8cqlM6JP1/EQV/OxwLpk923WPZfF3f3/reyY39c=; b=o5JHQhalgURDQ48MkxcEb6RdL3txddrGkAo5mjGJUqgaui0Gdird0f0fBq2auXYOTs NklDXXI5Dgj3Sk1g36tb08ABCBO7kdDvBOj4cVf6URH/1fF3GOyYiU1SuF7L49LRDFHN PMzi2RszsFAKaaHDmfbDNBdLRQ2IhvICCn1XL/rL2cNMmrWi6RHfKFUeV7/j5UhWN44k qAbv+I+tMPefTzrQJzFSbJcRsFEPLRfJWdKsbCXbxHV2kvT6Sqs5FVB4HDID0+rp3bzS oedKruWbgB1DQ4bjLHAf9f7VNXG2IVpSpCPCIEr7qrxf5Dvkr3sXtpbfKfp9s8QnTHjp HEQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pVryUjmw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l15-20020a17090a384f00b001e87471611dsi13411363pjf.145.2022.06.08.09.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:42:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pVryUjmw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DBE9D4889C; Wed, 8 Jun 2022 09:15:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245241AbiFHQPM (ORCPT + 99 others); Wed, 8 Jun 2022 12:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245245AbiFHQPK (ORCPT ); Wed, 8 Jun 2022 12:15:10 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 103B71339CC for ; Wed, 8 Jun 2022 09:15:08 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id n28so27776615edb.9 for ; Wed, 08 Jun 2022 09:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Tbbr8cqlM6JP1/EQV/OxwLpk923WPZfF3f3/reyY39c=; b=pVryUjmwn4whBpZYVa57ovLNVPxnEQjKuBNPxsdoHbh7hmx0ZFuQFGABiVHN6oMoI3 i4BRyjnH8n35ss+AkcXl4HIqx7Qk8R9+EdAJpoIIFIpxohXUfPTOCQrkOj9tNSaLaPWu tE6TZRJEzqsmnLTJNjrMtlQNAEV63ot8l/Z5FnHab3UxlxnbsETap47NCzjPFf4TDMrN +COlv0NWE7zzwjENxT/7Hx2pynkKhnUs+hWkeZP4CCHcJzKfKOdiZ/F00W7DH0pHjc5d yV9lMLhTd2pwMuEoiznqCtK+agVcEIR/9TF4LwXnuuJAMs8s6Anaoge6sLstwdF8xZm9 qYBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Tbbr8cqlM6JP1/EQV/OxwLpk923WPZfF3f3/reyY39c=; b=KRZV/ZFTtDTfP5zONv67//XqEipdjUDuwRwbaLAPUMb+HzXL/lEncWgYUHQpebkhpq Vuo4WRXOn5om314jKRmNuAIz4GmgV1L9u3iEge+nSkw1Yof9ad2TeYQzpA3xDdhoF144 5P+7PzuvRgDWv7j5F7YlkxBeAKT8eJVc7jVHCz2JJl8sFeLrz7Jx0cf4tCAfx+5grc0I AZxM4zPi4EiD6YgDWeoFzhM2kTuHJh3w4dBEHmKB/Y4edrY7RI+93lhlJeA+75vcqlk2 gGoNMboIBtF2BUTJJfG8rlNmE9s64/AekdIjdSDwJ6W5221V56Vhhuyx7ltjhhudJXs+ NCRw== X-Gm-Message-State: AOAM532wWgPwPg0iPjnQeXnDJ6exD/JJ8hQtqAgz3mdosnqP7nNExGwx 0fZmsF9R+DqN4EKUTT0XitdZov2bFRdPsKfebq5MhA== X-Received: by 2002:a05:6402:350e:b0:42f:b2c1:9393 with SMTP id b14-20020a056402350e00b0042fb2c19393mr29766337edd.11.1654704907120; Wed, 08 Jun 2022 09:15:07 -0700 (PDT) MIME-Version: 1.0 References: <20220608110734.2928245-1-tzungbi@kernel.org> <20220608110734.2928245-13-tzungbi@kernel.org> In-Reply-To: <20220608110734.2928245-13-tzungbi@kernel.org> From: Guenter Roeck Date: Wed, 8 Jun 2022 09:14:56 -0700 Message-ID: Subject: Re: [PATCH v3 12/23] platform/chrome: cros_ec_proto: handle empty payload in getting info legacy To: Tzung-Bi Shih Cc: Benson Leung , Guenter Roeck , "open list:CHROME HARDWARE PLATFORM SUPPORT" , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 8, 2022 at 4:08 AM Tzung-Bi Shih wrote: > > cros_ec_get_proto_info_legacy() expects to receive > sizeof(struct ec_response_hello) from send_command(). The payload is > valid only if the return value is positive. > > Return -EPROTO if send_command() returns 0 in > cros_ec_get_proto_info_legacy(). > > Signed-off-by: Tzung-Bi Shih Reviewed-by: Guenter Roeck > --- > Changes from v2: > - Separate Kunit test to another patch. > > drivers/platform/chrome/cros_ec_proto.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > index 04b9704ed302..473654f50bca 100644 > --- a/drivers/platform/chrome/cros_ec_proto.c > +++ b/drivers/platform/chrome/cros_ec_proto.c > @@ -356,7 +356,7 @@ static int cros_ec_get_proto_info_legacy(struct cros_ec_device *ec_dev) > struct cros_ec_command *msg; > struct ec_params_hello *params; > struct ec_response_hello *response; > - int ret; > + int ret, mapped; > > ec_dev->proto_version = 2; > > @@ -377,12 +377,18 @@ static int cros_ec_get_proto_info_legacy(struct cros_ec_device *ec_dev) > goto exit; > } > > - ret = cros_ec_map_error(msg->result); > - if (ret) { > + mapped = cros_ec_map_error(msg->result); > + if (mapped) { > + ret = mapped; > dev_err(ec_dev->dev, "EC responded to v2 hello with error: %d\n", msg->result); > goto exit; > } > > + if (ret == 0) { > + ret = -EPROTO; > + goto exit; > + } > + > response = (struct ec_response_hello *)msg->data; > if (response->out_data != 0xa1b2c3d4) { > dev_err(ec_dev->dev, > -- > 2.36.1.255.ge46751e96f-goog >