public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] KEYS: Propagate error code instead of returning -EINVAL
@ 2010-06-03 19:09 Dan Carpenter
  2010-06-04 10:08 ` David Howells
  2010-06-06 23:23 ` [patch] KEYS: Propagate error code instead of returning James Morris
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2010-06-03 19:09 UTC (permalink / raw)
  To: kernel-janitors

This is from a Smatch check I'm writing.

strncpy_from_user() returns -EFAULT on error so the first change just
silences a warning but doesn't change how the code works.

The other change is a bug fix because install_thread_keyring_to_cred()
can return a variety of errors such as -EINVAL, -EEXIST, -ENOMEM or 
-EKEYREVOKED.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 13074b4..6261745 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -33,7 +33,7 @@ static int key_get_type_from_user(char *type,
 	ret = strncpy_from_user(type, _type, len);
 
 	if (ret < 0)
-		return -EFAULT;
+		return ret;
 
 	if (ret = 0 || ret >= len)
 		return -EINVAL;
@@ -1080,7 +1080,7 @@ set:
 	return old_setting;
 error:
 	abort_creds(new);
-	return -EINVAL;
+	return ret;
 
 } /* end keyctl_set_reqkey_keyring() */
 

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

end of thread, other threads:[~2010-06-06 23:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-03 19:09 [patch] KEYS: Propagate error code instead of returning -EINVAL Dan Carpenter
2010-06-04 10:08 ` David Howells
2010-06-06 23:23 ` [patch] KEYS: Propagate error code instead of returning James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox