diff --git a/cmd/tpm.c b/cmd/tpm.c index add6bfb416e0ca7966652775acd684e50ac3e750..6edf3e9dc35de128f7a8dfa221da824d1979846a 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 8a622162740f9863b76b2cddfc80dee4886c1c7a..f428d454fbece41d01ca4610cc2201e5f0716502 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); }