Skip to content

Commit 3efc61d

Browse files
tiwaiThomas Zimmermann
authored andcommitted
fbdev: Fix invalid page access after closing deferred I/O devices
When a fbdev with deferred I/O is once opened and closed, the dirty pages still remain queued in the pageref list, and eventually later those may be processed in the delayed work. This may lead to a corruption of pages, hitting an Oops. This patch makes sure to cancel the delayed work and clean up the pageref list at closing the device for addressing the bug. A part of the cleanup code is factored out as a new helper function that is called from the common fb_release(). Reviewed-by: Patrik Jakobsson <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Tested-by: Miko Larsson <[email protected]> Fixes: 56c134f ("fbdev: Track deferred-I/O pages in pageref struct") Reviewed-by: Thomas Zimmermann <[email protected]> Signed-off-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 247a631 commit 3efc61d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

drivers/video/fbdev/core/fb_defio.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void fb_deferred_io_open(struct fb_info *info,
313313
}
314314
EXPORT_SYMBOL_GPL(fb_deferred_io_open);
315315

316-
void fb_deferred_io_cleanup(struct fb_info *info)
316+
void fb_deferred_io_release(struct fb_info *info)
317317
{
318318
struct fb_deferred_io *fbdefio = info->fbdefio;
319319
struct page *page;
@@ -327,6 +327,14 @@ void fb_deferred_io_cleanup(struct fb_info *info)
327327
page = fb_deferred_io_page(info, i);
328328
page->mapping = NULL;
329329
}
330+
}
331+
EXPORT_SYMBOL_GPL(fb_deferred_io_release);
332+
333+
void fb_deferred_io_cleanup(struct fb_info *info)
334+
{
335+
struct fb_deferred_io *fbdefio = info->fbdefio;
336+
337+
fb_deferred_io_release(info);
330338

331339
kvfree(info->pagerefs);
332340
mutex_destroy(&fbdefio->lock);

drivers/video/fbdev/core/fbmem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,10 @@ __releases(&info->lock)
14541454
struct fb_info * const info = file->private_data;
14551455

14561456
lock_fb_info(info);
1457+
#if IS_ENABLED(CONFIG_FB_DEFERRED_IO)
1458+
if (info->fbdefio)
1459+
fb_deferred_io_release(info);
1460+
#endif
14571461
if (info->fbops->fb_release)
14581462
info->fbops->fb_release(info,1);
14591463
module_put(info->fbops->owner);

include/linux/fb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ extern int fb_deferred_io_init(struct fb_info *info);
662662
extern void fb_deferred_io_open(struct fb_info *info,
663663
struct inode *inode,
664664
struct file *file);
665+
extern void fb_deferred_io_release(struct fb_info *info);
665666
extern void fb_deferred_io_cleanup(struct fb_info *info);
666667
extern int fb_deferred_io_fsync(struct file *file, loff_t start,
667668
loff_t end, int datasync);

0 commit comments

Comments
 (0)