[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251226111217.50747-1-alperyasinak1@gmail.com>
Date: Fri, 26 Dec 2025 14:12:16 +0300
From: Alper Ak <alperyasinak1@...il.com>
To: peterhuewe@....de,
jarkko@...nel.org
Cc: Alper Ak <alperyasinak1@...il.com>,
Jason Gunthorpe <jgg@...pe.ca>,
James Bottomley <James.Bottomley@...senPartnership.com>,
linux-integrity@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] tpm: tpm2-space: Skip handle check when context load returns -ENOENT
When tpm2_load_context() returns -ENOENT, the session is marked as
forgotten by setting session_tbl[i] to 0. Although tpm2_load_context()
also sets handle to 0 in this case, the subsequent comparison
"handle != space->session_tbl[i]" (0 != 0) is always false and serves
no purpose.
Add continue to skip this unnecessary comparison when load fails with
-ENOENT, making the control flow clearer and fix possible
uninitialized 'handle' variable.
Fixes: 4d57856a21ed2 ("tpm2: add session handle context saving and restoring to the space code")
Signed-off-by: Alper Ak <alperyasinak1@...il.com>
---
drivers/char/tpm/tpm2-space.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
index 60354cd53b5c..7dfbe07ecf5b 100644
--- a/drivers/char/tpm/tpm2-space.c
+++ b/drivers/char/tpm/tpm2-space.c
@@ -213,6 +213,7 @@ static int tpm2_load_space(struct tpm_chip *chip)
if (rc == -ENOENT) {
/* load failed, just forget session */
space->session_tbl[i] = 0;
+ continue;
} else if (rc) {
tpm2_flush_space(chip);
return rc;
--
2.43.0
Powered by blists - more mailing lists