Impact: fix trace read to conform to standards
Andrew Morton, Theodore Tso and H. Peter Anvin brought to my attention
that a userspace read should not return -EFAULT if it succeeded in
copying anything. It should only return -EFAULT if it failed to copy
at all.
This patch modifies the check of copy_from_user and updates the return
code appropriately.
I also used H. Peter Anvin's short cut rule to just test ret == count.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
        int len;
        int ret;
 
+       if (!cnt)
+               return 0;
+
        if (s->len <= s->readpos)
                return -EBUSY;
 
        if (cnt > len)
                cnt = len;
        ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);
-       if (ret)
+       if (ret == cnt)
                return -EFAULT;
 
+       cnt -= ret;
+
        s->readpos += len;
        return cnt;
 }
        ssize_t ret;
        size_t size;
 
+       if (!count)
+               return 0;
+
        /* Do we have previous read data to read? */
        if (info->read < PAGE_SIZE)
                goto read;
                size = count;
 
        ret = copy_to_user(ubuf, info->spare + info->read, size);
-       if (ret)
+       if (ret == size)
                return -EFAULT;
+       size -= ret;
+
        *ppos += size;
        info->read += size;