Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Axel Lin and committed by
Dmitry Torokhov
35b1da4e 30ebb7fa

+6 -3
+6 -3
drivers/input/touchscreen/edt-ft5x06.c
··· 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;