Skip to content

Commit

Permalink
vinput: Fix incorrect handling on raw_copy_to_user() failure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
visitorckw committed May 8, 2024
1 parent c068fa4 commit 0a23ecd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/vinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static ssize_t vinput_read(struct file *file, char __user *buffer, size_t count,
count = len - *offset;

if (raw_copy_to_user(buffer, buff + *offset, count))
count = -EFAULT;
return -EFAULT;

*offset += count;

Expand Down

0 comments on commit 0a23ecd

Please sign in to comment.