[Skiboot] [PATCH 2/2] tpm_extendl: don't extend and log when no tpm is registered

Claudio Carvalho cclaudio at linux.vnet.ibm.com
Mon Oct 31 14:13:41 AEDT 2016


This fixes tpm_extendl() to extend and log only when the list of
registered tpms is not empty.

Fixes: 3837c6f0cf4cffb5de874413eed755c0c698b076
Signed-off-by: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>
---
 libstb/status_codes.h | 1 +
 libstb/tpm_chip.c     | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/libstb/status_codes.h b/libstb/status_codes.h
index e67c17b..4896132 100644
--- a/libstb/status_codes.h
+++ b/libstb/status_codes.h
@@ -31,6 +31,7 @@
 #define STB_MEASURE_FAILED		-200
 
 /* TPM */
+#define STB_NO_TPM_INITIALIZED	 300
 #define STB_TPM_OVERFLOW	-300
 #define STB_TPM_TIMEOUT	-301
 
diff --git a/libstb/tpm_chip.c b/libstb/tpm_chip.c
index 0c81548..85464d9 100644
--- a/libstb/tpm_chip.c
+++ b/libstb/tpm_chip.c
@@ -236,6 +236,11 @@ int tpm_extendl(TPM_Pcr pcr,
 	failed = 0;
 	rc = 0;
 
+	if (list_empty(&tpm_list)) {
+		rc = STB_NO_TPM_INITIALIZED;
+		goto end;
+	}
+
 	list_for_each(&tpm_list, tpm, link) {
 		if (!tpm->enabled)
 			continue;
@@ -304,6 +309,7 @@ int tpm_extendl(TPM_Pcr pcr,
 	if (failed > 0)
 		rc = STB_MEASURE_FAILED;
 
+end:
 	if (tpm_measured)
 		*tpm_measured = measured;
 	if (tpm_failed)
-- 
1.9.1



More information about the Skiboot mailing list