提交 4303ef19 编写于 作者: D Dan Carpenter 提交者: Linus Torvalds

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: NDan Carpenter <error27@gmail.com>
Signed-off-by: NDavid Howells <dhowells@redhat.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 7e27d6e7
...@@ -33,7 +33,7 @@ static int key_get_type_from_user(char *type, ...@@ -33,7 +33,7 @@ static int key_get_type_from_user(char *type,
ret = strncpy_from_user(type, _type, len); ret = strncpy_from_user(type, _type, len);
if (ret < 0) if (ret < 0)
return -EFAULT; return ret;
if (ret == 0 || ret >= len) if (ret == 0 || ret >= len)
return -EINVAL; return -EINVAL;
...@@ -1080,7 +1080,7 @@ long keyctl_set_reqkey_keyring(int reqkey_defl) ...@@ -1080,7 +1080,7 @@ long keyctl_set_reqkey_keyring(int reqkey_defl)
return old_setting; return old_setting;
error: error:
abort_creds(new); abort_creds(new);
return -EINVAL; return ret;
} /* end keyctl_set_reqkey_keyring() */ } /* end keyctl_set_reqkey_keyring() */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册