Skip to contentSkip to conversation

tpm: Disable TPM on tpm2_create_primary() failure

PATCH New Jarkko Sakkinen 1 participant 1 message Nov 13, 2024

Subsystems (5)
lore
Share & tools
lore

Jarkko Sakkinen

author maintainer
#0 lore raw

PATCH 1/1 tpm: Disable TPM on tpm2_create_primary() failure

The earlier bug fix misplaced the error-label when dealing with the tpm2_create_primary() return value, which the original completely ignored.

---
 drivers/char/tpm/tpm2-sessions.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm2-sessions.c +5 -2
index a7c1b162251b..b70165b588ec 100644
@@ -953,10 +953,13 @@ static int tpm2_load_null(struct tpm_chip *chip, u32 *null_key)
 	/* Deduce from the name change TPM interference: */
 	dev_err(&chip->dev, "null key integrity check failed\n");
 	tpm2_flush_context(chip, tmp_null_key);
-	chip->flags |= TPM_CHIP_FLAG_DISABLE;
 
 err:
-	return rc ? -ENODEV : 0;
+	if (rc) {
+		chip->flags |= TPM_CHIP_FLAG_DISABLE;
+		rc = -ENODEV;
+	}
+	return rc;
 }
 
 /**
Signature · 1 line
2.47.0