Commit 35b1da4e1e1026b5195649170dfb9ebb52f808e0
Committed by
Dmitry Torokhov
1 parent
30ebb7fa0e
Exists in
master
and in
20 other branches
Input: edt-ft5x06 - return -EFAULT on copy_to_user() error
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>
Showing 1 changed file with 6 additions and 3 deletions Side-by-side Diff
drivers/input/touchscreen/edt-ft5x06.c
... | ... | @@ -566,9 +566,12 @@ |
566 | 566 | } |
567 | 567 | |
568 | 568 | read = min_t(size_t, count, tsdata->raw_bufsize - *off); |
569 | - error = copy_to_user(buf, tsdata->raw_buffer + *off, read); | |
570 | - if (!error) | |
571 | - *off += read; | |
569 | + if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) { | |
570 | + error = -EFAULT; | |
571 | + goto out; | |
572 | + } | |
573 | + | |
574 | + *off += read; | |
572 | 575 | out: |
573 | 576 | mutex_unlock(&tsdata->mutex); |
574 | 577 | return error ?: read; |