From patchwork Sat Mar 29 12:16:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elias Vanderstuyft X-Patchwork-Id: 3908291 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C3512BF540 for ; Sat, 29 Mar 2014 12:17:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF6DE20353 for ; Sat, 29 Mar 2014 12:17:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19F9C2034E for ; Sat, 29 Mar 2014 12:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751718AbaC2MQu (ORCPT ); Sat, 29 Mar 2014 08:16:50 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:57023 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751432AbaC2MQt (ORCPT ); Sat, 29 Mar 2014 08:16:49 -0400 Received: by mail-ee0-f45.google.com with SMTP id d17so5010206eek.32 for ; Sat, 29 Mar 2014 05:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=LwMffh3YX6Z/NQ/sA4MbFLv1fHSe2Wl0vhhx6qNtKKE=; b=mXCDcWMgHxaiJt5lGZ4aSCx6jmVdY4gg23jf432e3d3qESmEQnWLd4SlX3cFZrYJKZ IoAPhGqcaZAz35dJagvuZ9BxgTclJZK4dvwJjkYoAMLte08Ap6qxUfbHGXH85PWMJyjo 7z02wZb5LPgmodKJra9kGKaQRCcMcIyadbyBjHJI4hySMpwB8iZ6wTt/H2nlsxo8TFL5 wM38uTUJKG1f4h7N7Claq5ktRlyiES6JM+svxcN4mjjSBqOkgjVCeyRo+gDa8Eh4wkKw /8IwjwbN1CZ5xBVrCb3hzGmWYnIgKL0mo1lrx6xKtjgL3DPJs2HMYweGvwy5ibLhF3lX ofuQ== X-Received: by 10.15.43.77 with SMTP id w53mr17366873eev.10.1396095407710; Sat, 29 Mar 2014 05:16:47 -0700 (PDT) Received: from localhost.localdomain (94-224-61-60.access.telenet.be. [94.224.61.60]) by mx.google.com with ESMTPSA id 45sm18390464eeh.9.2014.03.29.05.16.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Mar 2014 05:16:46 -0700 (PDT) From: Elias Vanderstuyft To: dmitry.torokhov@gmail.com Cc: Elias Vanderstuyft , Anssi Hannula , =?UTF-8?q?Michal=20Mal=C3=BD?= , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/1] Input: don't modify the id of ioctl-provided ff effect on upload failure Date: Sat, 29 Mar 2014 13:16:36 +0100 Message-Id: <1396095396-23551-1-git-send-email-elias.vds@gmail.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a new (id == -1) ff effect was uploaded from userspace, ff-core.c::input_ff_upload() will have assigned a positive number to the new effect id. Currently, evdev.c::evdev_do_ioctl() will save this new id to userspace, regardless of whether the upload succeeded or not. On upload failure, this can be confusing because the dev->ff->effects[] array will not contain an element at the index of that new effect id. This patch fixes this by leaving the id unchanged after upload fails. Note: Unfortunately applications should still expect changed effect id for quite some time. This has been discussed on: http://www.mail-archive.com/linux-input@vger.kernel.org/msg08513.html ("ff-core effect id handling in case of a failed effect upload") Suggested-by: Dmitry Torokhov Signed-off-by: Elias Vanderstuyft Cc: Anssi Hannula Cc: Michal MalĂ˝ Cc: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- v2: Only added one line to the commit message to say what this patch actually does, instead of only stating the reason why it's submitted. drivers/input/evdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index a06e125..ce953d8 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -954,11 +954,13 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, return -EFAULT; error = input_ff_upload(dev, &effect, file); + if (error) + return error; if (put_user(effect.id, &(((struct ff_effect __user *)p)->id))) return -EFAULT; - return error; + return 0; } /* Multi-number variable-length handlers */