s390 keyboard.c: don't open-code strndup_user()
... especially not with off-by-ones (strnlen_user() already includes NUL into its count). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
8f3ba02dec
commit
b7310105ab
|
@ -433,12 +433,7 @@ do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry __user *u_kbs,
|
||||||
case KDSKBSENT:
|
case KDSKBSENT:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
len = strnlen_user(u_kbs->kb_string, sizeof(u_kbs->kb_string));
|
p = strndup_user(u_kbs->kb_string, sizeof(u_kbs->kb_string));
|
||||||
if (!len)
|
|
||||||
return -EFAULT;
|
|
||||||
if (len > sizeof(u_kbs->kb_string))
|
|
||||||
return -EINVAL;
|
|
||||||
p = memdup_user_nul(u_kbs->kb_string, len);
|
|
||||||
if (IS_ERR(p))
|
if (IS_ERR(p))
|
||||||
return PTR_ERR(p);
|
return PTR_ERR(p);
|
||||||
kfree(kbd->func_table[kb_func]);
|
kfree(kbd->func_table[kb_func]);
|
||||||
|
|
Loading…
Reference in New Issue