Skip to content

Commit aafa025

Browse files
fbdev: Make fb_release() return -ENODEV if fbdev was unregistered
A reference to the framebuffer device struct fb_info is stored in the file private data, but this reference could no longer be valid and must not be accessed directly. Instead, the file_fb_info() accessor function must be used since it does sanity checking to make sure that the fb_info is valid. This can happen for example if the registered framebuffer device is for a driver that just uses a framebuffer provided by the system firmware. In that case, the fbdev core would unregister the framebuffer device when a real video driver is probed and ask to remove conflicting framebuffers. The bug has been present for a long time but commit 27599aa ("fbdev: Hot-unplug firmware fb devices on forced removal") unmasked it since the fbdev core started unregistering the framebuffers' devices associated. Fixes: 27599aa ("fbdev: Hot-unplug firmware fb devices on forced removal") Reported-by: Maxime Ripard <maxime@cerno.tech> Reported-by: Junxiao Chang <junxiao.chang@intel.com> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patchwork.freedesktop.org/patch/msgid/20220502135014.377945-1-javierm@redhat.com
1 parent dc3ae06 commit aafa025

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/video/fbdev/core/fbmem.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,10 @@ fb_release(struct inode *inode, struct file *file)
14341434
__acquires(&info->lock)
14351435
__releases(&info->lock)
14361436
{
1437-
struct fb_info * const info = file->private_data;
1437+
struct fb_info * const info = file_fb_info(file);
1438+
1439+
if (!info)
1440+
return -ENODEV;
14381441

14391442
lock_fb_info(info);
14401443
if (info->fbops->fb_release)

0 commit comments

Comments
 (0)