aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cachefiles/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cachefiles/daemon.c')
-rw-r--r--fs/cachefiles/daemon.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index f601def05bdf..452e98dd7560 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -226,15 +226,9 @@ static ssize_t cachefiles_daemon_write(struct file *file,
226 return -EOPNOTSUPP; 226 return -EOPNOTSUPP;
227 227
228 /* drag the command string into the kernel so we can parse it */ 228 /* drag the command string into the kernel so we can parse it */
229 data = kmalloc(datalen + 1, GFP_KERNEL); 229 data = memdup_user_nul(_data, datalen);
230 if (!data) 230 if (IS_ERR(data))
231 return -ENOMEM; 231 return PTR_ERR(data);
232
233 ret = -EFAULT;
234 if (copy_from_user(data, _data, datalen) != 0)
235 goto error;
236
237 data[datalen] = '\0';
238 232
239 ret = -EINVAL; 233 ret = -EINVAL;
240 if (memchr(data, '\0', datalen)) 234 if (memchr(data, '\0', datalen))