From: Dan Carpenter Date: Fri, 11 Jun 2010 16:30:05 +0000 (+0100) Subject: KEYS: Propagate error code instead of returning -EINVAL X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4303ef19c6e6d16ea845c04b02b9cf086bcb8ed7;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git KEYS: Propagate error code instead of returning -EINVAL 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 Signed-off-by: David Howells Signed-off-by: Linus Torvalds --- diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index 13074b454743..6261745e4459 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() */