aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sbus
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-12-24 00:06:05 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-04 10:26:58 -0500
commit16e5c1fc36040e592128a164499bc25eb138a80f (patch)
treea080bd2eea306d5815c5a9eefb46180e2bedffb2 /drivers/sbus
parent7e935c7ca1e6c398f11edac5beabfc4348e3b3a4 (diff)
convert a bunch of open-coded instances of memdup_user_nul()
A _lot_ of ->write() instances were open-coding it; some are converted to memdup_user_nul(), a lot more remain... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/sbus')
-rw-r--r--drivers/sbus/char/openprom.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index 5843288f64bc..e077ebd89319 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -390,16 +390,9 @@ static int copyin_string(char __user *user, size_t len, char **ptr)
390 if ((ssize_t)len < 0 || (ssize_t)(len + 1) < 0) 390 if ((ssize_t)len < 0 || (ssize_t)(len + 1) < 0)
391 return -EINVAL; 391 return -EINVAL;
392 392
393 tmp = kmalloc(len + 1, GFP_KERNEL); 393 tmp = memdup_user_nul(user, len);
394 if (!tmp) 394 if (IS_ERR(tmp))
395 return -ENOMEM; 395 return PTR_ERR(tmp);
396
397 if (copy_from_user(tmp, user, len)) {
398 kfree(tmp);
399 return -EFAULT;
400 }
401
402 tmp[len] = '\0';
403 396
404 *ptr = tmp; 397 *ptr = tmp;
405 398