From 4cfe34e752ea635cdf619aea1281421d2e7b7606 Mon Sep 17 00:00:00 2001 From: Kuan-Wei Chiu Date: Thu, 9 May 2024 01:12:39 +0800 Subject: [PATCH] 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. --- examples/vinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vinput.c b/examples/vinput.c index 78ee0cc0..59f25841 100644 --- a/examples/vinput.c +++ b/examples/vinput.c @@ -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;