linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Orzel <michalorzel.eng@gmail.com>
To: David Howells <dhowells@redhat.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>
Cc: Michal Orzel <michalorzel.eng@gmail.com>,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH 3/5] keys: Remove redundant assignments
Date: Thu, 31 Mar 2022 19:33:56 +0200	[thread overview]
Message-ID: <20220331173358.40939-3-michalorzel.eng@gmail.com> (raw)
In-Reply-To: <20220331173358.40939-1-michalorzel.eng@gmail.com>

Get rid of redundant assignments which end up in values not being
read either because they are overwritten or the function ends.

Reported by clang-tidy [deadcode.DeadStores]

Signed-off-by: Michal Orzel <michalorzel.eng@gmail.com>
---
 security/keys/process_keys.c | 1 -
 security/keys/request_key.c  | 6 ++----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index b5d5333ab330..8bdd6410f79a 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -92,7 +92,6 @@ int look_up_user_keyrings(struct key **_user_keyring,
 		return PTR_ERR(reg_keyring);
 
 	down_write(&user_ns->keyring_sem);
-	ret = 0;
 
 	/* Get the user keyring.  Note that there may be one in existence
 	 * already as it may have been pinned by a session, but the user_struct
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 2da4404276f0..ad29023c9518 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -116,7 +116,7 @@ static int call_sbin_request_key(struct key *authkey, void *aux)
 {
 	static char const request_key[] = "/sbin/request-key";
 	struct request_key_auth *rka = get_request_key_auth(authkey);
-	const struct cred *cred = current_cred();
+	const struct cred *cred;
 	key_serial_t prkey, sskey;
 	struct key *key = rka->target_key, *keyring, *session, *user_session;
 	char *argv[9], *envp[3], uid_str[12], gid_str[12];
@@ -506,9 +506,7 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,
 			kdebug("cons failed");
 			goto construction_failed;
 		}
-	} else if (ret == -EINPROGRESS) {
-		ret = 0;
-	} else {
+	} else if (ret != -EINPROGRESS) {
 		goto error_put_dest_keyring;
 	}
 
-- 
2.25.1


  parent reply	other threads:[~2022-03-31 17:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31 17:33 [PATCH 1/5] apparmor: Remove redundant assignments Michal Orzel
2022-03-31 17:33 ` [PATCH 2/5] integrity: " Michal Orzel
2022-03-31 17:33 ` Michal Orzel [this message]
2022-04-03  8:06   ` [PATCH 3/5] keys: " Jarkko Sakkinen
2022-03-31 17:33 ` [PATCH 5/5] smack: " Michal Orzel
2022-03-31 18:44   ` Casey Schaufler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220331173358.40939-3-michalorzel.eng@gmail.com \
    --to=michalorzel.eng@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=serge@hallyn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).