Thread (7 messages) 7 messages, 3 authors, 2021-05-11
STALE1846d
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 1/1] trusted-keys: match tpm_get_ops on all return paths

From: Ben Boeckel <hidden>
Date: 2021-04-29 19:24:40
Also in: keyrings, linux-integrity, lkml
Subsystem: keys-trusted, keys/keyrings, security subsystem, the rest · Maintainers: James Bottomley, Jarkko Sakkinen, Mimi Zohar, David Howells, Paul Moore, James Morris, "Serge E. Hallyn", Linus Torvalds

From: Ben Boeckel <redacted>

The `tpm_get_ops` call at the beginning of the function is not paired
with a `tpm_put_ops` on this return path.

Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
Reported-by: Dan Carpenter <redacted>
Signed-off-by: Ben Boeckel <redacted>
---
 security/keys/trusted-keys/trusted_tpm2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
index 617fabd4d913..0165da386289 100644
--- a/security/keys/trusted-keys/trusted_tpm2.c
+++ b/security/keys/trusted-keys/trusted_tpm2.c
@@ -336,9 +336,9 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
 			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;
-- 
2.30.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help