Skip to content

Commit

Permalink
Input: edt-ft5x06 - return -EFAULT on copy_to_user() error
Browse files Browse the repository at this point in the history
copy_to_user() returns the number of bytes remaining, but we want a
negative error code here.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Axel Lin authored and Dmitry Torokhov committed Sep 19, 2012
1 parent 30ebb7f commit 35b1da4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/input/touchscreen/edt-ft5x06.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,12 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
}

read = min_t(size_t, count, tsdata->raw_bufsize - *off);
error = copy_to_user(buf, tsdata->raw_buffer + *off, read);
if (!error)
*off += read;
if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) {
error = -EFAULT;
goto out;
}

*off += read;
out:
mutex_unlock(&tsdata->mutex);
return error ?: read;
Expand Down

0 comments on commit 35b1da4

Please sign in to comment.