From: Christophe Ricard Date: Thu, 21 Jan 2016 22:19:13 +0000 (+0100) Subject: tpm: Fix fault in case CONFIG_DM_TPM is set without any TPM X-Git-Tag: KARO-TXSD-2017-03-15~2025^2~35 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0e37d4c2c631b0e94b7e891a5b37650d9bbd143c;p=karo-tx-uboot.git tpm: Fix fault in case CONFIG_DM_TPM is set without any TPM In case CONFIG_DM_TPM was set without any TPM chipset configured a fault was generated (NULL pointer access). Reviewed-by: Simon Glass Signed-off-by: Christophe Ricard --- diff --git a/cmd/tpm.c b/cmd/tpm.c index add6bfb416..6edf3e9dc3 100644 --- a/cmd/tpm.c +++ b/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 8a62216274..f428d454fb 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); }