diff options
Diffstat (limited to 'fs/afs/proc.c')
| -rw-r--r-- | fs/afs/proc.c | 25 | 
1 files changed, 6 insertions, 19 deletions
diff --git a/fs/afs/proc.c b/fs/afs/proc.c index 24a905b076fd..2853b4095344 100644 --- a/fs/afs/proc.c +++ b/fs/afs/proc.c @@ -230,14 +230,9 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,  	if (size <= 1 || size >= PAGE_SIZE)  		return -EINVAL; -	kbuf = kmalloc(size + 1, GFP_KERNEL); -	if (!kbuf) -		return -ENOMEM; - -	ret = -EFAULT; -	if (copy_from_user(kbuf, buf, size) != 0) -		goto done; -	kbuf[size] = 0; +	kbuf = memdup_user_nul(buf, size); +	if (IS_ERR(kbuf)) +		return PTR_ERR(kbuf);  	/* trim to first NL */  	name = memchr(kbuf, '\n', size); @@ -315,15 +310,9 @@ static ssize_t afs_proc_rootcell_write(struct file *file,  	if (size <= 1 || size >= PAGE_SIZE)  		return -EINVAL; -	ret = -ENOMEM; -	kbuf = kmalloc(size + 1, GFP_KERNEL); -	if (!kbuf) -		goto nomem; - -	ret = -EFAULT; -	if (copy_from_user(kbuf, buf, size) != 0) -		goto infault; -	kbuf[size] = 0; +	kbuf = memdup_user_nul(buf, size); +	if (IS_ERR(kbuf)) +		return PTR_ERR(kbuf);  	/* trim to first NL */  	s = memchr(kbuf, '\n', size); @@ -337,9 +326,7 @@ static ssize_t afs_proc_rootcell_write(struct file *file,  	if (ret >= 0)  		ret = size;	/* consume everything, always */ -infault:  	kfree(kbuf); -nomem:  	_leave(" = %d", ret);  	return ret;  }  | 
