* [PATCH v2 1/1] Input: don't modify the id of ioctl-provided ff effect on upload failure
@ 2014-03-29 12:16 Elias Vanderstuyft
2014-03-29 19:12 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Elias Vanderstuyft @ 2014-03-29 12:16 UTC (permalink / raw)
To: dmitry.torokhov
Cc: Elias Vanderstuyft, Anssi Hannula, Michal Malý, linux-input,
linux-kernel
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 <dmitry.torokhov@gmail.com>
Signed-off-by: Elias Vanderstuyft <elias.vds@gmail.com>
Cc: Anssi Hannula <anssi.hannula@iki.fi>
Cc: Michal Malý <madcatxster@devoid-pointer.net>
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 */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/1] Input: don't modify the id of ioctl-provided ff effect on upload failure
2014-03-29 12:16 [PATCH v2 1/1] Input: don't modify the id of ioctl-provided ff effect on upload failure Elias Vanderstuyft
@ 2014-03-29 19:12 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-03-29 19:12 UTC (permalink / raw)
To: Elias Vanderstuyft
Cc: Anssi Hannula, Michal Malý, linux-input, linux-kernel
On Sat, Mar 29, 2014 at 01:16:36PM +0100, Elias Vanderstuyft wrote:
> 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 <dmitry.torokhov@gmail.com>
> Signed-off-by: Elias Vanderstuyft <elias.vds@gmail.com>
> Cc: Anssi Hannula <anssi.hannula@iki.fi>
> Cc: Michal Malý <madcatxster@devoid-pointer.net>
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
Applied, thank you, and sorry for the delay.
> ---
> 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 */
> --
> 1.8.3.1
>
--
Dmitry
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-29 19:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-29 12:16 [PATCH v2 1/1] Input: don't modify the id of ioctl-provided ff effect on upload failure Elias Vanderstuyft
2014-03-29 19:12 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).