|
@@ -527,14 +527,18 @@ ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos,
|
|
const void *from, size_t available)
|
|
const void *from, size_t available)
|
|
{
|
|
{
|
|
loff_t pos = *ppos;
|
|
loff_t pos = *ppos;
|
|
|
|
+ size_t ret;
|
|
|
|
+
|
|
if (pos < 0)
|
|
if (pos < 0)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
- if (pos >= available)
|
|
|
|
|
|
+ if (pos >= available || !count)
|
|
return 0;
|
|
return 0;
|
|
if (count > available - pos)
|
|
if (count > available - pos)
|
|
count = available - pos;
|
|
count = available - pos;
|
|
- if (copy_to_user(to, from + pos, count))
|
|
|
|
|
|
+ ret = copy_to_user(to, from + pos, count);
|
|
|
|
+ if (ret == count)
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
|
|
+ count -= ret;
|
|
*ppos = pos + count;
|
|
*ppos = pos + count;
|
|
return count;
|
|
return count;
|
|
}
|
|
}
|