Linux Integrity Measurement development
 help / color / mirror / Atom feed
* [PATCH v2] tpm_tis_spi: fix:release chip select when flow control fails
@ 2023-05-22  7:01 shaopeijie
  2023-05-22  8:17 ` Paul Menzel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: shaopeijie @ 2023-05-22  7:01 UTC (permalink / raw)
  To: jarkko; +Cc: peterhuewe, jgg, linux-integrity, linux-kernel, Peijie Shao

From: Peijie Shao <shaopeijie@cestc.cn>

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 <shaopeijie@cestc.cn>
---
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




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-24  3:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-22  7:01 [PATCH v2] tpm_tis_spi: fix:release chip select when flow control fails shaopeijie
2023-05-22  8:17 ` Paul Menzel
2023-05-24  2:52   ` Jarkko Sakkinen
2023-05-23  2:45 ` shaopeijie
2023-05-23  2:45 ` [PATCH v3] tpm_tis_spi: Release " shaopeijie
2023-05-24  2:06   ` Jarkko Sakkinen
2023-05-24  3:14   ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox