[U-Boot] [PATCH 1/2] tpm: Fix fault in case CONFIG_DM_TPM is set without any TPM
Christophe Ricard
christophe.ricard at gmail.com
Sun Jan 17 00:17:19 CET 2016
In case CONFIG_DM_TPM was set without any TPM chipset configured a fault
was generated (NULL pointer access).
Signed-off-by: Christophe Ricard <christophe-h.ricard at st.com>
---
common/cmd_tpm.c | 2 +-
lib/tpm.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c
index add6bfb..6edf3e9 100644
--- a/common/cmd_tpm.c
+++ b/common/cmd_tpm.c
@@ -448,7 +448,7 @@ static int get_tpm(struct udevice **devp)
int rc;
rc = uclass_first_device(UCLASS_TPM, devp);
- if (rc) {
+ if (rc || !*devp) {
printf("Could not find TPM (ret=%d)\n", rc);
return CMD_RET_FAILURE;
}
diff --git a/lib/tpm.c b/lib/tpm.c
index 8a62216..f428d45 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -262,7 +262,7 @@ int tpm_init(void)
struct udevice *dev;
err = uclass_first_device(UCLASS_TPM, &dev);
- if (err)
+ if (err || !dev)
return err;
return tpm_open(dev);
}
--
2.5.0
More information about the U-Boot
mailing list