Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fbdev: flush deferred work in fb_deferred_io_fsync()

The driver's fsync() is supposed to flush any pending operation to
hardware. It is implemented in this driver by cancelling the queued
deferred IO first, then schedule it for "immediate execution" by calling
schedule_delayed_work() again with delay=0. However, setting delay=0
only means the work is scheduled immediately, it does not mean the work
is executed immediately. There is no guarantee that the work is finished
after schedule_delayed_work() returns. After this driver's fsync()
returns, there can still be pending work. Furthermore, if close() is
called by users immediately after fsync(), the pending work gets
cancelled and fsync() may do nothing.

To ensure that the deferred IO completes, use flush_delayed_work()
instead. Write operations to this driver either write to the device
directly, or invoke schedule_delayed_work(); so by flushing the
workqueue, it can be guaranteed that all previous writes make it to the
device.

Fixes: 5e841b88d23d ("fb: fsync() method for deferred I/O flush.")
Cc: stable@vger.kernel.org
Signed-off-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Nam Cao and committed by
Helge Deller
15e4c1f4 dee56ccb

+1 -5
+1 -5
drivers/video/fbdev/core/fb_defio.c
··· 132 132 return 0; 133 133 134 134 inode_lock(inode); 135 - /* Kill off the delayed work */ 136 - cancel_delayed_work_sync(&info->deferred_work); 137 - 138 - /* Run it immediately */ 139 - schedule_delayed_work(&info->deferred_work, 0); 135 + flush_delayed_work(&info->deferred_work); 140 136 inode_unlock(inode); 141 137 142 138 return 0;