]> git.baikalelectronics.ru Git - kernel.git/commitdiff
trusted-keys: match tpm_get_ops on all return paths
authorBen Boeckel <mathstuf@gmail.com>
Thu, 29 Apr 2021 19:21:56 +0000 (15:21 -0400)
committerJarkko Sakkinen <jarkko@kernel.org>
Wed, 12 May 2021 19:36:37 +0000 (22:36 +0300)
The `tpm_get_ops` call at the beginning of the function is not paired
with a `tpm_put_ops` on this return path.

Cc: stable@vger.kernel.org
Fixes: e2f54dda576f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
security/keys/trusted-keys/trusted_tpm2.c

index 617fabd4d913b81caa5e0537e12477671dbe3a77..0165da386289c315cc581aa45fbd4ecfa5b88693 100644 (file)
@@ -336,9 +336,9 @@ out:
                        rc = -EPERM;
        }
        if (blob_len < 0)
-               return blob_len;
-
-       payload->blob_len = blob_len;
+               rc = blob_len;
+       else
+               payload->blob_len = blob_len;
 
        tpm_put_ops(chip);
        return rc;