Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2689272iof; Wed, 8 Jun 2022 09:59:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS2hA8OoQf3N/3C21rwq/SiqmV9LqFtAYEzGXvaN+valnlzVvmD2cd5G0Ud8LSMhvxeV8/ X-Received: by 2002:a17:90a:fb93:b0:1e8:a809:af4d with SMTP id cp19-20020a17090afb9300b001e8a809af4dmr143452pjb.7.1654707569749; Wed, 08 Jun 2022 09:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654707569; cv=none; d=google.com; s=arc-20160816; b=gIIGtbn0av8zuSKmyI78nHhpxww0+pMtH+rgGy3yEGv8hKulUvy/Unklb55ZMXFUVW hZusyvqNownghUwbkba/oohdtIzSE+TGqgDFjwq3BML1rXWHHcNFlLjOqFA7SbizdrQT 4ZCq9amrX4OH9E6KHqUcKe2sw297UE+DQjwgi8Ee2tuUoXNb7E3IazakqGTKZcc5zYAe cPUr4TMJ9A8V/kfOJSQxFa0rpc9ScjcbPQt6VFE+7j/s7wu7KiGwPS7ywHfV+O7wW7N2 UAMFAbKgFsmwIK1qr8a8urwBwzBwD/ieqbJHazMaBMzg7DwwbINLJfKClYbuMMeIN05e e05w== 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=eIhsgd4qYNDkbHY1tSv0TAemIX3YjvX24oBE2vbHP9s=; b=OiaFndJyI6P9vlEKDDO2Xr2kxPbEh1+jjhdfbXPXU9E3Sxi568h2LiQEupDvu+Wu5F HVAw59M66+t1MUF1NVT48sHtTcwt/yIfOpFkR96yhsUFTF3UVwXsAK/OkRQFImUPcIQq YXOgx+audkQ5gja8CIRgX68AMl8FUw8f80yd8fLI4H3+e3W7zaJ+cFiGLjCcStUfBMyg JJFm7NdOEIYc+Lrz3/3cHt+byxI1Oilizea+lRyG/GiweDU7Qj6YuN/z1BUiTnqo1Bxt M0BFaFXZZB/KkJxRDzIOPAbVvOeRcmVyPZ10BhEEwtLUB3FI52/3zmEJk2okBR/gJmW3 OEWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=q4REp7vJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id e16-20020a637450000000b003fb04d0b55dsi30434538pgn.565.2022.06.08.09.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:59:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=q4REp7vJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 685C9265622; Wed, 8 Jun 2022 09:30:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245553AbiFHQ3I (ORCPT + 99 others); Wed, 8 Jun 2022 12:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245295AbiFHQ2M (ORCPT ); Wed, 8 Jun 2022 12:28:12 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E9D1FE38D for ; Wed, 8 Jun 2022 09:28:10 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id y19so42506584ejq.6 for ; Wed, 08 Jun 2022 09:28:09 -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=eIhsgd4qYNDkbHY1tSv0TAemIX3YjvX24oBE2vbHP9s=; b=q4REp7vJNJCw7clXuyO3mj6Yi54h3u6xe9uA3nbJ7FWErSDyW4H4FiTzxAwD0uUZfU rM924OIqUo+ecqazXEQwTxo+pevPbqJkO9lGWVq5e/0lsQqp22kxsIvtP8o6qNm634vW X0DbF/nhg27S6az45V0JockL4wwUZfeyuqgtJxh2Xxdt0cCaVja+9kvo65UabcSX5tpZ gLP9dg8RJTj9bATBOqu8pPNaiU8gU4vnbbeee+YPxkPXmVLr9Lup+z7NX+sU6VNyWCyO ZULLu7dAJgWnt83TgddQryzx6212MqNGHCytA+99L5FYm9kT+DdlwLqlTwxq6/cP3Gol s5Bw== 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=eIhsgd4qYNDkbHY1tSv0TAemIX3YjvX24oBE2vbHP9s=; b=pzs2Yl4nXlEH17rldc5omaBmZzFSTKq8KO5C30APhCm9RvH0Z9YN/wbGmA5PFxxxBc 4v4XEHshgWFlxpjwPQMNmTlhsHD0ua2/6CFZAOApWYcMbj+YEwXWOLErJqugCWJylarz dMZvHN1avgH8mCvdWBn0W749FYnah85Sc/3IWrgmfk9OU/NyB3OAm2BwICr385BcVeJP H0rH5QvjplK6HDzFqPB6aN7xLYSl3rPepXsVLdpqTg5AQne3R8tw5lbgt7mpwNjqycNY ov5V7tvkL/Nh4BkdYzxYHALviUo+vqOPnhPc+MUJSPhxSNb0XKTH/EEiRmpDQ30dDT8F h63w== X-Gm-Message-State: AOAM533RnvoOA1FYxe8kf5Zs2CjJyqUyO9F6CyMiZJrrmd31Fv+HrIKc VC8HdK06cqgd1SyAlkC5VG5udxNGbTnZTMXFUJ51m5C0uGv2xmHY X-Received: by 2002:a17:907:1ca8:b0:70c:68ce:dade with SMTP id nb40-20020a1709071ca800b0070c68cedademr29501960ejc.723.1654705688387; Wed, 08 Jun 2022 09:28:08 -0700 (PDT) MIME-Version: 1.0 References: <20220608110734.2928245-1-tzungbi@kernel.org> <20220608110734.2928245-19-tzungbi@kernel.org> In-Reply-To: From: Guenter Roeck Date: Wed, 8 Jun 2022 09:27:57 -0700 Message-ID: Subject: Re: [PATCH v3 18/23] platform/chrome: cros_ec_proto: check `msg->result` in getting cmd mask 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 9:23 AM Guenter Roeck wrote: > > On Wed, Jun 8, 2022 at 4:08 AM Tzung-Bi Shih wrote: > > > > cros_ec_get_host_command_version_mask() should check if EC wasn't happy > > by checking `msg->result`. > > > > Use cros_ec_map_error() and return the error code if any. > > > > Signed-off-by: Tzung-Bi Shih > > --- > > No v2. New and separated from the original series. > > > > drivers/platform/chrome/cros_ec_proto.c | 21 +++++++++++++-------- > > 1 file changed, 13 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > > index 06bc7db1213e..6a5771361383 100644 > > --- a/drivers/platform/chrome/cros_ec_proto.c > > +++ b/drivers/platform/chrome/cros_ec_proto.c > > @@ -428,13 +428,12 @@ static int cros_ec_get_proto_info_legacy(struct cros_ec_device *ec_dev) > > * the caller has ec_dev->lock mutex or the caller knows there is > > * no other command in progress. > > */ > > -static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, > > - u16 cmd, u32 *mask) > > +static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, u16 cmd, u32 *mask) > > { > > struct ec_params_get_cmd_versions *pver; > > struct ec_response_get_cmd_versions *rver; > > struct cros_ec_command *msg; > > - int ret; > > + int ret, mapped; > > > > msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), > > GFP_KERNEL); > > @@ -450,14 +449,20 @@ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, > > pver->cmd = cmd; > > > > ret = send_command(ec_dev, msg); > > - if (ret > 0) { > > - rver = (struct ec_response_get_cmd_versions *)msg->data; > > - *mask = rver->version_mask; > > - ret = 0; > > + if (ret < 0) > > + goto exit; > > + > > + mapped = cros_ec_map_error(msg->result); > > + if (mapped) { > > + ret = mapped; > > + goto exit; > > } > > > What if ret == 0 ? Is that valid ? > Never mind, addressed in a follow-up patch. Reviewed-by: Guenter Roeck > Thanks, > Guenter > > > + rver = (struct ec_response_get_cmd_versions *)msg->data; > > + *mask = rver->version_mask; > > + ret = 0; > > +exit: > > kfree(msg); > > - > > return ret; > > } > > > > -- > > 2.36.1.255.ge46751e96f-goog > >