Merge tag 'mfd-next-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
[linux-2.6-microblaze.git] / security / keys / trusted-keys / trusted_tpm1.c
index 74d8209..493eb91 100644 (file)
@@ -403,9 +403,12 @@ static int osap(struct tpm_buf *tb, struct osapsess *s,
        int ret;
 
        ret = tpm_get_random(chip, ononce, TPM_NONCE_SIZE);
-       if (ret != TPM_NONCE_SIZE)
+       if (ret < 0)
                return ret;
 
+       if (ret != TPM_NONCE_SIZE)
+               return -EIO;
+
        tpm_buf_reset(tb, TPM_TAG_RQU_COMMAND, TPM_ORD_OSAP);
        tpm_buf_append_u16(tb, type);
        tpm_buf_append_u32(tb, handle);
@@ -496,8 +499,12 @@ static int tpm_seal(struct tpm_buf *tb, uint16_t keytype,
                goto out;
 
        ret = tpm_get_random(chip, td->nonceodd, TPM_NONCE_SIZE);
+       if (ret < 0)
+               return ret;
+
        if (ret != TPM_NONCE_SIZE)
-               goto out;
+               return -EIO;
+
        ordinal = htonl(TPM_ORD_SEAL);
        datsize = htonl(datalen);
        pcrsize = htonl(pcrinfosize);
@@ -601,9 +608,12 @@ static int tpm_unseal(struct tpm_buf *tb,
 
        ordinal = htonl(TPM_ORD_UNSEAL);
        ret = tpm_get_random(chip, nonceodd, TPM_NONCE_SIZE);
+       if (ret < 0)
+               return ret;
+
        if (ret != TPM_NONCE_SIZE) {
                pr_info("trusted_key: tpm_get_random failed (%d)\n", ret);
-               return ret;
+               return -EIO;
        }
        ret = TSS_authhmac(authdata1, keyauth, TPM_NONCE_SIZE,
                           enonce1, nonceodd, cont, sizeof(uint32_t),
@@ -791,7 +801,7 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
                case Opt_migratable:
                        if (*args[0].from == '0')
                                pay->migratable = 0;
-                       else
+                       else if (*args[0].from != '1')
                                return -EINVAL;
                        break;
                case Opt_pcrlock:
@@ -1013,8 +1023,12 @@ static int trusted_instantiate(struct key *key,
        case Opt_new:
                key_len = payload->key_len;
                ret = tpm_get_random(chip, payload->key, key_len);
+               if (ret < 0)
+                       goto out;
+
                if (ret != key_len) {
                        pr_info("trusted_key: key_create failed (%d)\n", ret);
+                       ret = -EIO;
                        goto out;
                }
                if (tpm2)