Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2585501rwd; Mon, 22 May 2023 00:46:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45bDJUbF0PSJtmulc/dH9qyCJtH8+p307j4hbcxpMXFjTjccik3DoFxbJ1xzTDlSjPi7/3 X-Received: by 2002:a05:6a00:1a15:b0:63b:5c82:e21a with SMTP id g21-20020a056a001a1500b0063b5c82e21amr13066304pfv.1.1684741595258; Mon, 22 May 2023 00:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684741595; cv=none; d=google.com; s=arc-20160816; b=Ne4IkT4KTvwAhGaMSJtZB6MfZS+Vq0QvLoa4Tg4JpMWGG1Wt8VxNNJkQ13ll+dF1Ve xogC3pdqa6BzDC8qSiC9/Ys++o49loTxHLBehw6KHmvKHgJNBmoWvId0NUA8ceHj1/t8 3vDbMaGyphrKFOITEwjLzOxpmr3ZoCAas9Xfd0Qa5kzQ61RFuV/YPB+LBC1SxH8bsHFO 4hzhWdtQ2s8JSbnpujEYTbH16zOtWIfqcR0Pf29kb+1ordeh81YtIT8gFJfUkJiPUu9E aOjwX0Rggim14S+faN+Xs0CBvWjK8fgQYdU0oOSBJXv/4NRK7ZISoeoz4skKjMfxfdAn SVMg== 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 :message-id:date:subject:cc:to:from; bh=gnacIujfUV1+AwQiSmst3F0onxBgLJhsA+/zhjGydE8=; b=sJ56MOCDOExK33+wyW763xshbr8/cpoYC0XMLo0bWLbi6LuExun2e2ESfgtR5WqXH6 odHSz+dPFBRwHJYA6H2Qdq2qTa0LJoxXX41BCZyxnfVLdHIAehsQXASCuVC5qnFnrdW8 tKyj5q+LMCeyr8vFOSUoHnTJf0taaQ+gdLz/7fOXClqsGydBEam8radHRxbJVJVo3wKO AAEp6NTcPwUF0XkvsHW9bJTIwcCWp24/ZW2ThQ38ewJGkeCmw4WHKc9/xFT4Z6EtJIQp 15KH9nyLbvB0r25tBv6hS3BVeuxLfsGvzPGTLKTRBt2PbOr0uxCyM1L9vchv4212m275 irtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w189-20020a6382c6000000b00530b7eca08dsi4654537pgd.51.2023.05.22.00.46.20; Mon, 22 May 2023 00:46:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232026AbjEVHOT (ORCPT + 99 others); Mon, 22 May 2023 03:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231887AbjEVHOD (ORCPT ); Mon, 22 May 2023 03:14:03 -0400 X-Greylist: delayed 324 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 22 May 2023 00:13:34 PDT Received: from smtp.cecloud.com (sg-smtp01.cecloud.com [13.251.65.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8150F10FC for ; Mon, 22 May 2023 00:13:34 -0700 (PDT) Received: from smtp.cecloud.com (unknown [103.166.174.66]) by smtp.cecloud.com (Postfix) with ESMTP id 4AD83169 for ; Mon, 22 May 2023 07:08:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.cecloud.com (Postfix) with ESMTP id 17E69900113; Mon, 22 May 2023 15:01:53 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [111.48.58.11]) by smtp.cecloud.com (postfix) whith ESMTP id P2917246T281458643890544S1684738912085108_; Mon, 22 May 2023 15:01:53 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: shaopeijie@cestc.cn X-SENDER: shaopeijie@cestc.cn X-LOGIN-NAME: shaopeijie@cestc.cn X-FST-TO: jarkko@kernel.org X-RCPT-COUNT: 6 X-SENDER-IP: 111.48.58.11 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: shaopeijie@cestc.cn To: jarkko@kernel.org Cc: peterhuewe@gmx.de, jgg@ziepe.ca, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Peijie Shao Subject: [PATCH v2] tpm_tis_spi: fix:release chip select when flow control fails Date: Mon, 22 May 2023 15:01:40 +0800 Message-Id: <20230522070140.33719-1-shaopeijie@cestc.cn> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,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 From: Peijie Shao The failure paths in tpm_tis_spi_transfer() do not deactivate chip select. Send an empty message (cs_select == 0) to overcome this. Signed-off-by: Peijie Shao --- Changes since v1: 1. Deactive cs all of the failure path, not only flow control. 2. change and update comments. --- drivers/char/tpm/tpm_tis_spi_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c index 1f5207974..9bfaba092 100644 --- a/drivers/char/tpm/tpm_tis_spi_main.c +++ b/drivers/char/tpm/tpm_tis_spi_main.c @@ -136,6 +136,14 @@ int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len, } exit: + if (ret < 0) { + /* Deactivate chip select */ + memset(&spi_xfer, 0, sizeof(spi_xfer)); + spi_message_init(&m); + spi_message_add_tail(&spi_xfer, &m); + spi_sync_locked(phy->spi_device, &m); + } + spi_bus_unlock(phy->spi_device->master); return ret; } -- 2.39.1