From 5d4a08742ab48982be500151a0dfa7c509096416 Mon Sep 17 00:00:00 2001 From: xucee Date: Thu, 19 Dec 2024 19:17:13 +0800 Subject: [PATCH] reset tcti_common->state in tcti_device_receive when return TSS2_TCTI_RC_IO_ERROR Signed-off-by: xcfxr --- src/tss2-tcti/tcti-device.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/tss2-tcti/tcti-device.c b/src/tss2-tcti/tcti-device.c index 00045c16d..69548022a 100644 --- a/src/tss2-tcti/tcti-device.c +++ b/src/tss2-tcti/tcti-device.c @@ -186,7 +186,8 @@ tcti_device_receive ( if (rc_poll < 0) { LOG_ERROR ("Failed to poll for response from fd %d, got errno %d: %s", tcti_dev->fd, errno, strerror(errno)); - return TSS2_TCTI_RC_IO_ERROR; + rc = TSS2_TCTI_RC_IO_ERROR; + goto out; } else if (rc_poll == 0) { LOG_INFO ("Poll timed out on fd %d.", tcti_dev->fd); return TSS2_TCTI_RC_TRY_AGAIN; @@ -195,7 +196,8 @@ tcti_device_receive ( if (size < 0 || size != TPM_HEADER_SIZE) { LOG_ERROR ("Failed to get response size fd %d, got errno %d: %s", tcti_dev->fd, errno, strerror (errno)); - return TSS2_TCTI_RC_IO_ERROR; + rc = TSS2_TCTI_RC_IO_ERROR; + goto out; } } else { LOG_ERROR ("Header could not be received"); @@ -246,7 +248,8 @@ tcti_device_receive ( if (rc_poll < 0) { LOG_ERROR ("Failed to poll for response from fd %d, got errno %d: %s", tcti_dev->fd, errno, strerror (errno)); - return TSS2_TCTI_RC_IO_ERROR; + rc = TSS2_TCTI_RC_IO_ERROR; + goto out; } else if (rc_poll == 0) { LOG_INFO ("Poll timed out on fd %d.", tcti_dev->fd); return TSS2_TCTI_RC_TRY_AGAIN; @@ -262,7 +265,8 @@ tcti_device_receive ( if (size < 0) { LOG_ERROR ("Failed to read response from fd %d, got errno %d: %s", tcti_dev->fd, errno, strerror (errno)); - return TSS2_TCTI_RC_IO_ERROR; + rc = TSS2_TCTI_RC_IO_ERROR; + goto out; } } if (size == 0) {