dect
/
linux-2.6
Archived
13
0
Fork 0

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 <error27@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Dan Carpenter 2010-06-11 17:30:05 +01:00 committed by Linus Torvalds
parent 7e27d6e778
commit 4303ef19c6
1 changed files with 2 additions and 2 deletions

View File

@ -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() */