Skip to content

Commit

Permalink
KEYS: Propagate error code instead of returning -EINVAL
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
error27 authored and torvalds committed Jun 27, 2010
1 parent 7e27d6e commit 4303ef1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions security/keys/keyctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1080,7 +1080,7 @@ long keyctl_set_reqkey_keyring(int reqkey_defl)
return old_setting;
error:
abort_creds(new);
return -EINVAL;
return ret;

} /* end keyctl_set_reqkey_keyring() */

Expand Down

0 comments on commit 4303ef1

Please sign in to comment.