From: Axel Lin Date: Wed, 19 Sep 2012 22:56:23 +0000 (-0700) Subject: Input: edt-ft5x06 - return -EFAULT on copy_to_user() error X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=35b1da4e1e1026b5195649170dfb9ebb52f808e0;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Dmitry Torokhov --- diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index b06a5e3a665e..64957770b522 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -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;