skip copy_to_user() when r->ret is negative error number in mckernel_procfs_read().

refs #370
This commit is contained in:
Susumu Komae
2015-01-08 12:38:06 +09:00
committed by postpeta
parent e3eb7e68bc
commit 74f0aec478

View File

@ -380,13 +380,15 @@ retry:
goto retry; goto retry;
} }
if (copy_to_user(buf, kern_buffer, r->ret)) { if (r->ret > 0) {
kprintf("ERROR: mckernel_procfs_read: copy_to_user failed.\n"); if (copy_to_user(buf, kern_buffer, r->ret)) {
ret = -EFAULT; kprintf("ERROR: mckernel_procfs_read: copy_to_user failed.\n");
goto out; ret = -EFAULT;
} goto out;
}
*ppos += r->ret; *ppos += r->ret;
}
ret = r->ret; ret = r->ret;
out: out: