Skip to content

Commit 0926409

Browse files
mrpippydtor
authored andcommitted
Input: evdev - call input_flush_device() on release(), not flush()
input_flush_device() should only be called once the struct file is being released and no open descriptors remain, but evdev_flush() was calling it whenever a file descriptor was closed. This caused uploaded force-feedback effects to be erased when a process did a dup()/close() on the event FD, called system(), etc. Call input_flush_device() from evdev_release() instead. Reported-by: Mathieu Maret <[email protected]> Signed-off-by: Brendan Shanks <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 1893150 commit 0926409

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

drivers/input/evdev.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,20 +326,6 @@ static int evdev_fasync(int fd, struct file *file, int on)
326326
return fasync_helper(fd, file, on, &client->fasync);
327327
}
328328

329-
static int evdev_flush(struct file *file, fl_owner_t id)
330-
{
331-
struct evdev_client *client = file->private_data;
332-
struct evdev *evdev = client->evdev;
333-
334-
mutex_lock(&evdev->mutex);
335-
336-
if (evdev->exist && !client->revoked)
337-
input_flush_device(&evdev->handle, file);
338-
339-
mutex_unlock(&evdev->mutex);
340-
return 0;
341-
}
342-
343329
static void evdev_free(struct device *dev)
344330
{
345331
struct evdev *evdev = container_of(dev, struct evdev, dev);
@@ -453,6 +439,10 @@ static int evdev_release(struct inode *inode, struct file *file)
453439
unsigned int i;
454440

455441
mutex_lock(&evdev->mutex);
442+
443+
if (evdev->exist && !client->revoked)
444+
input_flush_device(&evdev->handle, file);
445+
456446
evdev_ungrab(evdev, client);
457447
mutex_unlock(&evdev->mutex);
458448

@@ -1310,7 +1300,6 @@ static const struct file_operations evdev_fops = {
13101300
.compat_ioctl = evdev_ioctl_compat,
13111301
#endif
13121302
.fasync = evdev_fasync,
1313-
.flush = evdev_flush,
13141303
.llseek = no_llseek,
13151304
};
13161305

0 commit comments

Comments
 (0)