Message ID | 20210908140308.18491-9-jaharkes@cs.cmu.edu (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Coda updates for -next | expand |
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index 240669f51eac..7e23cb22d394 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -122,14 +122,10 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, hdr.opcode, hdr.unique); nbytes = size; } - dcbuf = kvmalloc(nbytes, GFP_KERNEL); - if (!dcbuf) { - retval = -ENOMEM; - goto out; - } - if (copy_from_user(dcbuf, buf, nbytes)) { - kvfree(dcbuf); - retval = -EFAULT; + + dcbuf = vmemdup_user(buf, nbytes); + if (IS_ERR(dcbuf)) { + retval = PTR_ERR(dcbuf); goto out; }