diff mbox series

keys: Do not check the retval of commit_creds in join_session_keyring

Message ID c8ccba0bbcb9147fb220fd18b3b5e1e951b6d5fd.1591960478.git.suse-tux@gmx.de (mailing list archive)
State New
Headers show
Series keys: Do not check the retval of commit_creds in join_session_keyring | expand

Commit Message

Marcus Hüwe June 12, 2020, 11:25 a.m. UTC
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(-)

--
2.26.2

Comments

Jarkko Sakkinen June 17, 2020, 1:46 a.m. UTC | #1
On Fri, Jun 12, 2020 at 01:25:33PM +0200, Marcus Huewe wrote:
> 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>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

David, can you pick this up to your tree (give that a generic
keyring change)?

/Jarkko
Marcus Hüwe July 28, 2020, 11:06 a.m. UTC | #2
On 2020-06-17 04:46:24 +0300, Jarkko Sakkinen wrote:
> On Fri, Jun 12, 2020 at 01:25:33PM +0200, Marcus Huewe wrote:
> > 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>
>
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
>
> David, can you pick this up to your tree (give that a generic
> keyring change)?
>
Just a gentle ping - any news on this?:)

(I'm perfectly fine if you don't want to take it... (since it is
just a minor cleanup and no bugfix))


Marcus
Jarkko Sakkinen Aug. 17, 2020, 9:17 p.m. UTC | #3
On Tue, Jul 28, 2020 at 01:06:35PM +0200, Marcus Hüwe wrote:
> On 2020-06-17 04:46:24 +0300, Jarkko Sakkinen wrote:
> > On Fri, Jun 12, 2020 at 01:25:33PM +0200, Marcus Huewe wrote:
> > > 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>
> >
> > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> >
> > David, can you pick this up to your tree (give that a generic
> > keyring change)?
> >
> Just a gentle ping - any news on this?:)
> 
> (I'm perfectly fine if you don't want to take it... (since it is
> just a minor cleanup and no bugfix))
> 
> 
> Marcus

I just came from two weeks of vacation and one week of network
connectivity issues (could not connect to the company VPN).

I still think that David should at least ack this.

/Jarkko
diff mbox series

Patch

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;
 	}