Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2675791iof; Wed, 8 Jun 2022 09:41:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtxMoZe1VudlN5S+/5I1mNplGsbNMZlG4HM6WnGLU8GeZAi6xrT1YH1k9M+U4uqbV3ICwa X-Received: by 2002:a17:902:8e8b:b0:168:a135:d636 with SMTP id bg11-20020a1709028e8b00b00168a135d636mr1178958plb.140.1654706463674; Wed, 08 Jun 2022 09:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654706463; cv=none; d=google.com; s=arc-20160816; b=QwDPH5jIOq0Bicq7jnGFSuKEm7GGIhswMLaOeChNOeIAKzdRenXsrORJG82qh5n4vE 8urvQ45jG7T84VjbdtyHRmCKD/ha7psKqsejOs3lDoNNhnBCrf/Na6JeiBuqEQElgFu6 zz/oA3mNiVrhldncty1QNA2rAnwcK/BCxw0fIERSFdbnZ3gH4lOnT1P3RTyV7r+a+tLP Z3CMd7Ede0h6C968hoGH8c90rlmfuLLYfPfklu7EnOgmTFVKGmTaz72ZpcT/aUR8kPW3 KZ+u39Y+bS17SsdlhHGSjIFoCI1N+aGaMq7ry1sd/GKgLet9vnYi9eZuGFsEix0Z1xGI uXmg== 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=OpAXdwZORFKOvufIunvkEJrAFgZQ4NyOlXoZC5h0a6c=; b=zVCk4vzQA4K9IePzhlYSqm0AgX/EinjtugFEbxmm54Zr/vA8jHpsUM7i6xyo9L1FHl ahxM3qDA6QXMkHdXqzdRMzMVs4qVFO9LN75d3ViGMTDi6FCGju92cNxiCjHgXPEgdrOR 9Ecr7A6a3yulTZou1nlE5p4oDM51ao89v9bACNgyW9YJObrNrLbMrqyiBJiQJ7YEU01w X2ch8GFYDva54v9vgmKtu3kVCuIiL81MwOynmS2P6NS6Fjdmd4PTI9g+5AmquVjITF0O BOP7YIcDsJlSyQ+6NNL9xyjmOkWb4csf6NvAHx1We0cxc0fQs2lrgZ57Ev0AxdKIiQLn 86IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GJCPf0tM; 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 s25-20020a639e19000000b003aa90e6d50bsi30926838pgd.45.2022.06.08.09.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:41:03 -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=GJCPf0tM; 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 480D5427C1; Wed, 8 Jun 2022 09:14:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245231AbiFHQOB (ORCPT + 99 others); Wed, 8 Jun 2022 12:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245217AbiFHQN7 (ORCPT ); Wed, 8 Jun 2022 12:13:59 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E5D62C671 for ; Wed, 8 Jun 2022 09:13:58 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id v1so31750729ejg.13 for ; Wed, 08 Jun 2022 09:13:58 -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=OpAXdwZORFKOvufIunvkEJrAFgZQ4NyOlXoZC5h0a6c=; b=GJCPf0tMR5KB3tq7Gq+jOWVHZ2cU2+4uYOTuLelzQMdvxjByTt5ghKXjWHrT5QS13V 86ZK1gL1SSML3H/VJI8zoFMPVRmNZ3mCVZ1S1eZ78ofZrBMXOYI5noo/sJDSxqSM+PZE wigVLL5OjMxYX5cKwqdS7EDmQrjYLHC7H4ahxV0vekgUeBk7BFSdcANbzkOUFVkQRpnm BscwDT5cHAGWXydy0U/F2QyVg66/SspdTcoRLognJcaKwezYd8Q7u+9g9J290mI9cBmL fqDSfjMHZuY/02kkjvb7Lr+TnTLFjk6jmU+O/sWd56hO08eVW+u3Pr7cmIT9OUHb144z dvRg== 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=OpAXdwZORFKOvufIunvkEJrAFgZQ4NyOlXoZC5h0a6c=; b=7KmkPW7jmZlx/4e3a+NkTB99oA2ldk2PRF0peozwELMwK8hsDwW/Q75eVukNrRjwNN CccUcOOJT6fODyGst7qQvcyqqkmKjyYktBDv+mi9S7IQ/H1aLKa5Odsk4ab97kZtyugv MUWItM+2qemZ+0gOReEkCI3Hb7vfrGVfnyOoLsC5qGR+C6R0ZgIQpVQbBlc3JLoh3b1H Utarg0I7JCegyKbEpDrP+s8mguhwBMejbJFJAF/rNMntHHPhHC5TKN7XhTdNiqNkmdyv R9J/PPtE3NbBD7Y19WKMqQCwNvrF3cYJ+VONnnV3FfaFJtGqOxGwaUVWu6WnngxoG2jP johg== X-Gm-Message-State: AOAM532ZuBIMAb1R9IvR3b+DmZDG5Eype5bNzaC1LnkVoYfho8/xQwvI e3lZihIhCUu4HRbYOVQUHG1FoqsrwDxP+KaXqvPLmw== X-Received: by 2002:a17:906:85cb:b0:70b:ffb4:b0e with SMTP id i11-20020a17090685cb00b0070bffb40b0emr28556697ejy.533.1654704835154; Wed, 08 Jun 2022 09:13:55 -0700 (PDT) MIME-Version: 1.0 References: <20220608110734.2928245-1-tzungbi@kernel.org> <20220608110734.2928245-10-tzungbi@kernel.org> In-Reply-To: <20220608110734.2928245-10-tzungbi@kernel.org> From: Guenter Roeck Date: Wed, 8 Jun 2022 09:13:44 -0700 Message-ID: Subject: Re: [PATCH v3 09/23] platform/chrome: cros_ec_proto: handle empty payload in getting proto info 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() expects to receive > sizeof(struct ec_response_get_protocol_info) 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(). > > 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 | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > index 893b76703da6..6f5be9e5ede4 100644 > --- a/drivers/platform/chrome/cros_ec_proto.c > +++ b/drivers/platform/chrome/cros_ec_proto.c > @@ -314,6 +314,11 @@ static int cros_ec_get_proto_info(struct cros_ec_device *ec_dev, int devidx) > goto exit; > } > > + if (ret == 0) { > + ret = -EPROTO; > + goto exit; > + } > + > info = (struct ec_response_get_protocol_info *)msg->data; > > switch (devidx) { > -- > 2.36.1.255.ge46751e96f-goog >