All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] keys: Do not check the retval of commit_creds in join_session_keyring
@ 2019-09-10 14:07 Marcus Huewe
  2019-10-14 13:06 ` Marcus Hüwe
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Marcus Huewe @ 2019-09-10 14:07 UTC (permalink / raw)
  To: keyrings

Do not check the return value of the commit_creds call in
join_session_keyring in order to make the code more concise.
Since commit_creds always returns 0, the if-statement is not needed
and the session keyring's serial can be directly assigned to the
"ret" variable.

Signed-off-by: Marcus Huewe <suse-tux@gmx.de>
---
 security/keys/process_keys.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 09541de31f2f..e7cd1ff84709 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -840,7 +840,7 @@ long join_session_keyring(const char *name)
 	const struct cred *old;
 	struct cred *new;
 	struct key *keyring;
-	long ret, serial;
+	long ret;

 	new = prepare_creds();
 	if (!new)
@@ -853,10 +853,8 @@ long join_session_keyring(const char *name)
 		if (ret < 0)
 			goto error;

-		serial = new->session_keyring->serial;
-		ret = commit_creds(new);
-		if (ret == 0)
-			ret = serial;
+		ret = new->session_keyring->serial;
+		commit_creds(new);
 		goto okay;
 	}

--
2.22.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-17 21:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-10 14:07 [PATCH] keys: Do not check the retval of commit_creds in join_session_keyring Marcus Huewe
2019-10-14 13:06 ` Marcus Hüwe
2020-06-12 11:25 ` Marcus Huewe
2020-06-17  1:46 ` Jarkko Sakkinen
2020-07-28 11:06 ` Marcus Hüwe
2020-08-17 21:17 ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.