In case CONFIG_DM_TPM was set without any TPM chipset configured a fault
was generated (NULL pointer access).

Reviewed-by: Simon Glass <s...@chromium.org>
Signed-off-by: Christophe Ricard <christophe-h.ric...@st.com>
---

Changes in v2:
- Adding Reviewed-by: Simon Glass <s...@chromium.org>

 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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to