linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] evm: Move two error code assignments in evm_set_key()
@ 2017-01-24 18:44 SF Markus Elfring
  0 siblings, 0 replies; only message in thread
From: SF Markus Elfring @ 2017-01-24 18:44 UTC (permalink / raw)
  To: linux-ima-devel, linux-security-module, James Morris, Mimi Zohar,
	Serge E. Hallyn
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Jan 2017 19:37:20 +0100

A local variable was set to an error code in two cases before a concrete
error situation was detected. Thus move the corresponding assignments into
if branches to indicate a software failure there.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/integrity/evm/evm_crypto.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index d7f282d75cc1..71bc204e2ee8 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -53,12 +53,14 @@ int evm_set_key(void *key, size_t keylen)
 {
 	int rc;
 
-	rc = -EBUSY;
-	if (test_and_set_bit(EVM_SET_KEY_BUSY, &evm_set_key_flags))
+	if (test_and_set_bit(EVM_SET_KEY_BUSY, &evm_set_key_flags)) {
+		rc = -EBUSY;
 		goto busy;
-	rc = -EINVAL;
-	if (keylen > MAX_KEY_SIZE)
+	}
+	if (keylen > MAX_KEY_SIZE) {
+		rc = -EINVAL;
 		goto inval;
+	}
 	memcpy(evmkey, key, keylen);
 	evm_initialized |= EVM_INIT_HMAC;
 	pr_info("key initialized\n");
-- 
2.11.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-24 18:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 18:44 [PATCH] evm: Move two error code assignments in evm_set_key() SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).