From patchwork Sun Feb 23 14:18:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elias Vanderstuyft X-Patchwork-Id: 3703851 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 2B9AFBF13A for ; Sun, 23 Feb 2014 14:18:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41DA820172 for ; Sun, 23 Feb 2014 14:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EE732012B for ; Sun, 23 Feb 2014 14:18:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751118AbaBWOSR (ORCPT ); Sun, 23 Feb 2014 09:18:17 -0500 Received: from mail-ve0-f175.google.com ([209.85.128.175]:41650 "EHLO mail-ve0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbaBWOSR (ORCPT ); Sun, 23 Feb 2014 09:18:17 -0500 Received: by mail-ve0-f175.google.com with SMTP id oy12so508966veb.20 for ; Sun, 23 Feb 2014 06:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=ftilLfkII3jtZfxpTd1CG/9Q17gJ5maGThiSqpn7Uz4=; b=ncnoAVaowdIxWUjhBA8NQxKBDNtS8jDTkWUEZw03J1/PP376TZiRfAS3wAaRnz8zny bgBE8YlkcDd18UokpW+2hJLMFksgTtR/zwFqfPiOPCyGePsmAD4ZDeXndtHPBtSVACiy 4f+HSP5GrK5ZJYhhQd4jmkpvxF1ZFZDhLRPV38ccGwXlkK2ZRQWKAQb6OV/b4+XW2FFZ 2NiDKKQBEVRtPg3zgOfcI2d3CrVPmdfMYDF1tVfV4ObsOud0GggZyCue8Y+BWH5uiDdi 6ntTI5gxKP8truBYV76kyKbAtxjukI+8uTeG4CvGZdh8CbIAqOt9CYpcZIYtJjEpJsiG HnTg== MIME-Version: 1.0 X-Received: by 10.52.168.39 with SMTP id zt7mr8323338vdb.42.1393165096020; Sun, 23 Feb 2014 06:18:16 -0800 (PST) Received: by 10.220.19.67 with HTTP; Sun, 23 Feb 2014 06:18:15 -0800 (PST) Date: Sun, 23 Feb 2014 15:18:15 +0100 Message-ID: Subject: [PATCH 1/1] Input: don't modify the id of ioctl-provided ff effect on upload failure From: Elias Vanderstuyft To: Dmitry Torokhov , Anssi Hannula Cc: linux-input@vger.kernel.org, =?ISO-8859-1?Q?Michal_Mal=FD?= 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.3 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 From: Elias Vanderstuyft 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. 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 --- drivers/input/evdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/input/evdev.c 2014-02-23 14:21:19.980606615 +0100 +++ b/drivers/input/evdev.c 2014-02-23 14:25:04.417118859 +0100 @@ -954,11 +954,13 @@ static long evdev_do_ioctl(struct file * 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 */