From patchwork Mon Sep 17 05:12:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: axel lin X-Patchwork-Id: 1464981 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D463DDFFFF for ; Mon, 17 Sep 2012 05:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660Ab2IQFND (ORCPT ); Mon, 17 Sep 2012 01:13:03 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]:51167 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751450Ab2IQFNB (ORCPT ); Mon, 17 Sep 2012 01:13:01 -0400 Received: by oago6 with SMTP id o6so4375423oag.19 for ; Sun, 16 Sep 2012 22:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:mime-version; bh=ijxzmW7TN7daua1J4ZqaNjs27veAaNphH4QkQFRqf1Q=; b=qq4lFbBWxT99ZPxGv57LhWAr1gRgUecKAenpXj0nGf6Ths4ffd3PR1QzzPeo2uvjRJ Pof/U5mV5mESGsRpUKCmwBfCZxg+z+eat2pIXJhu0qUMG1e2gFMxkPieHctjEN3wlux3 IJ6kQF2XKVsQxVsm9nlGJX4DRsTzyLRJMhEW+lfcjHfl4M0nzAMRmWnc+c2fHtsLPtPO F6YuEQiFquU2xEDo3LL4pHG92/bzfRlczWlrADzyBlbJaGD2DHx7o1/zTbSqqbGLtPSg wZYcGXQsMB65K5W6/K5LIS9VSB3qB8P6SwWX33ZNj7YzdhLxuYdsLCVclgpzx7dxuvgu 59dw== Received: by 10.60.1.106 with SMTP id 10mr10643757oel.84.1347858781032; Sun, 16 Sep 2012 22:13:01 -0700 (PDT) Received: from [218.173.171.238] (218-173-171-238.dynamic.hinet.net. [218.173.171.238]) by mx.google.com with ESMTPS id q3sm7760779oef.0.2012.09.16.22.12.58 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 16 Sep 2012 22:13:00 -0700 (PDT) Message-ID: <1347858772.8376.1.camel@phoenix> Subject: [PATCH] Input: edt-ft5x06 - return -EFAULT on copy_to_user() error From: Axel Lin To: Dmitry Torokhov Cc: Simon Budig , Henrik Rydberg , linux-input@vger.kernel.org Date: Mon, 17 Sep 2012 13:12:52 +0800 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org copy_to_user() returns the number of bytes remaining, but we want a negative error code here. Signed-off-by: Axel Lin --- drivers/input/touchscreen/edt-ft5x06.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index bf00b32..02e9dab 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -567,7 +567,9 @@ 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) + if (error) + error = -EFAULT; + else *off += read; out: mutex_unlock(&tsdata->mutex);