Skip to content

Commit

Permalink
Input: don't modify the id of ioctl-provided ff effect on upload failure
Browse files Browse the repository at this point in the history
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/[email protected]/msg08513.html
("ff-core effect id handling in case of a failed effect upload")

Suggested-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Elias Vanderstuyft <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
Eliasvan authored and dtor committed Mar 29, 2014
1 parent 8a0435d commit fc7392a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit fc7392a

Please sign in to comment.