Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2418320iof; Wed, 8 Jun 2022 04:42:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGfDFS0nL1qqkdxzQrgwJOUXD6ROKcPjA9TLLqgtg8E0RDhlx9e7nK5iw5MGeyt1tq9/oJ X-Received: by 2002:a63:1d62:0:b0:3fd:ebcd:13a4 with SMTP id d34-20020a631d62000000b003fdebcd13a4mr9698111pgm.151.1654688537521; Wed, 08 Jun 2022 04:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654688537; cv=none; d=google.com; s=arc-20160816; b=gm6o/qo5gX3jr9/oCIcPgraU94SxAT0RSb7ZzHa7KNluuTsty3Nt4Oce34mrZr+ZG+ VV2BTe2fY6Gcepwn9XuRP9I6kGUiGOqoq60ZQX3opxqC/XmPh9HyWKwG6FhoUzRRuz/B Pr7YepeK6zKkvIahw/xDbdctH5iBadpl4aBVrjRkYZ+3V2Gw7qW3CMmlE1CsZtAZ9hr6 NjzUP94QR4EFQamUUDRX3o3y/dp+oBhU1UEEI9HnP2KhTiaEWHq8skdbmotD2SJgal+v bm9kxCbIrSXIDgKS6GRsaOncJn7AbYhl04WN7DubseWNklFzRb0g/f3x9Ki4YpPAaa/y 6lTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IjSwZDZ/DomhJE3/z4GcXWTlt7mv+s9zKj5dsENawWE=; b=kYLdFVEoO6E5DwIUxH9SKt945CCEk6ojtCMZ4MsQu3c3mno9SWJrfMokbSNiNgg9sx gNKztiGWjUX98l3kspWNR+WxAiM8oZ7WdnXCo7ppFLee9cEnXRNrs4OGrzYlb7IzsWIY +Txo85cjEFYxCg7U2Opy4W4vd/sMtjtYkcuv/UD0WN2ebwFxYfcbBV88pCdLBrIsWJRZ aQcngTqxklDNoQRbsdx3e5G2GFlaasdJkJouPZ1Pw7PNNU/tuYOKzkcbNI8FZpmfIEB+ XpzTbvK5T+iaTqs7OkJjHpeRErExl/gU5ul14jjbBbin0UuJWOOvq7rA2MCUyxW9jjMy Q25Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dn1BoIeX; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l189-20020a6388c6000000b003fe30ec8267si2329200pgd.612.2022.06.08.04.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 04:42:17 -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=@kernel.org header.s=k20201202 header.b=dn1BoIeX; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3CF5B244149; Wed, 8 Jun 2022 04:11:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238121AbiFHLKA (ORCPT + 99 others); Wed, 8 Jun 2022 07:10:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237804AbiFHLIR (ORCPT ); Wed, 8 Jun 2022 07:08:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1BED1C287F for ; Wed, 8 Jun 2022 04:08:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8532C6160D for ; Wed, 8 Jun 2022 11:08:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 166B7C385A2; Wed, 8 Jun 2022 11:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654686493; bh=UMfDSCsZHz1ZMzu0+7xplVRluayGlh2A7KTsd2h7WmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dn1BoIeXoBkNeOBhVdH53LyXtnFgSnPuWGMbvu3Bwl6X/5glCRJK5aAplHSnsE7Sp URBu2ZzBNgeJ6DHOBuyrR5YF57foeFG//Pvv27QppQsCNhPCng3HD9tXjObF+5TXUO ru6Ouk0DaN4F494COrfydlUyxfNfeie1odlqC67GoxZEev/UPFGD3K/XWzbiLsrpwB Napx+mt14WrwcwIu68xvKoita2twgphFgP3GQYdlwd9hUyqFjMLd1df9FThVHkoLUB QntBnvPhXzRmRkXR+ETgUjY22Ec/OToS0L+f+qojsFCW23FtKtQHk4r3DS2B3k3qnB HbTmV0ro50uzg== From: Tzung-Bi Shih To: bleung@chromium.org, groeck@chromium.org Cc: chrome-platform@lists.linux.dev, tzungbi@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 20/23] platform/chrome: cros_ec_proto: handle empty payload in getting cmd mask Date: Wed, 8 Jun 2022 11:07:31 +0000 Message-Id: <20220608110734.2928245-21-tzungbi@kernel.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608110734.2928245-1-tzungbi@kernel.org> References: <20220608110734.2928245-1-tzungbi@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 cros_ec_get_host_command_version_mask() expects to receive sizeof(struct ec_response_get_cmd_versions) 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_host_command_version_mask(). Signed-off-by: Tzung-Bi Shih --- No v2. New and separated from the original series. 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 6a5771361383..9e95f9e4b2f8 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -458,6 +458,11 @@ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, goto exit; } + if (ret == 0) { + ret = -EPROTO; + goto exit; + } + rver = (struct ec_response_get_cmd_versions *)msg->data; *mask = rver->version_mask; ret = 0; -- 2.36.1.255.ge46751e96f-goog