فهرست منبع

vinput: Fix incorrect handling on raw_copy_to_user() failure

When raw_copy_to_user() failed in vinput_read(), the function would set
'count' to -EFAULT and then subtract EFAULT from '*offset'. However,
modifying '*offset' on raw_copy_to_user() failure was incorrect. Fix
this behavior by changing count = -EFAULT to return -EFAULT.
Kuan-Wei Chiu 11 ماه پیش
والد
کامیت
0a23ecd027
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      examples/vinput.c

+ 1 - 1
examples/vinput.c

@@ -106,7 +106,7 @@ static ssize_t vinput_read(struct file *file, char __user *buffer, size_t count,
         count = len - *offset;
         count = len - *offset;
 
 
     if (raw_copy_to_user(buffer, buff + *offset, count))
     if (raw_copy_to_user(buffer, buff + *offset, count))
-        count = -EFAULT;
+        return -EFAULT;
 
 
     *offset += count;
     *offset += count;