Revert "fbdev: Make fb_release() return -ENODEV if fbdev was unregistered"

[ Upstream commit 135332f34b ]

This reverts commit aafa025c76. That commit
attempted to fix a NULL pointer dereference, caused by the struct fb_info
associated with a framebuffer device to not longer be valid when the file
descriptor was closed.

The issue was exposed by commit 27599aacba ("fbdev: Hot-unplug firmware
fb devices on forced removal"), which added a new path that goes through
the struct device removal instead of directly unregistering the fb.

Most fbdev drivers have issues with the fb_info lifetime, because call to
framebuffer_release() from their driver's .remove callback, rather than
doing from fbops.fb_destroy callback. This meant that due to this switch,
the fb_info was now destroyed too early, while references still existed,
while before it was simply leaked.

The patch we're reverting here reinstated that leak, hence "fixed" the
regression. But the proper solution is to fix the drivers to not release
the fb_info too soon.

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220504115917.758787-1-javierm@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Javier Martinez Canillas 2022-05-04 13:59:17 +02:00 committed by Greg Kroah-Hartman
parent 98a9984b9c
commit 388c23c1e9

View file

@ -1438,10 +1438,7 @@ fb_release(struct inode *inode, struct file *file)
__acquires(&info->lock) __acquires(&info->lock)
__releases(&info->lock) __releases(&info->lock)
{ {
struct fb_info * const info = file_fb_info(file); struct fb_info * const info = file->private_data;
if (!info)
return -ENODEV;
lock_fb_info(info); lock_fb_info(info);
if (info->fbops->fb_release) if (info->fbops->fb_release)