diff options
author | Elias Vanderstuyft <elias.vds@gmail.com> | 2014-03-29 15:08:45 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-03-29 15:13:09 -0400 |
commit | fc7392aa1b20debc7f398acc39ffc817630f11e6 (patch) | |
tree | 135856bdb6fef8d7809ffe4e195c70c972a5af6a /drivers/input/evdev.c | |
parent | 8a0435d958fb36d93b8df610124a0e91e5675c82 (diff) |
Input: don't modify the id of ioctl-provided ff effect on upload failure
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>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r-- | drivers/input/evdev.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index a06e12552886..ce953d895f5b 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, | |||
954 | return -EFAULT; | 954 | return -EFAULT; |
955 | 955 | ||
956 | error = input_ff_upload(dev, &effect, file); | 956 | error = input_ff_upload(dev, &effect, file); |
957 | if (error) | ||
958 | return error; | ||
957 | 959 | ||
958 | if (put_user(effect.id, &(((struct ff_effect __user *)p)->id))) | 960 | if (put_user(effect.id, &(((struct ff_effect __user *)p)->id))) |
959 | return -EFAULT; | 961 | return -EFAULT; |
960 | 962 | ||
961 | return error; | 963 | return 0; |
962 | } | 964 | } |
963 | 965 | ||
964 | /* Multi-number variable-length handlers */ | 966 | /* Multi-number variable-length handlers */ |