drm/fb-helper: generic: Don't take module ref for fbcon
authorNoralf Trønnes <noralf@tronnes.org>
Sun, 10 Feb 2019 13:10:39 +0000 (14:10 +0100)
committerNoralf Trønnes <noralf@tronnes.org>
Thu, 21 Feb 2019 11:24:28 +0000 (12:24 +0100)
It's now safe to let fbcon unbind automatically on fbdev unregister.
The crash problem was fixed in commit 2122b40580dd
("fbdev: fbcon: Fix unregister crash when more than one framebuffer")

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20190210131039.52664-13-noralf@tronnes.org
drivers/gpu/drm/drm_fb_helper.c

index 0e9349ff2d16a64dd6628ab47de8f9ab0271d632..04d23cb430bf0bb8dffa03ea5fb0916f1a37c27e 100644 (file)
@@ -3024,7 +3024,8 @@ static int drm_fbdev_fb_open(struct fb_info *info, int user)
 {
        struct drm_fb_helper *fb_helper = info->par;
 
-       if (!try_module_get(fb_helper->dev->driver->fops->owner))
+       /* No need to take a ref for fbcon because it unbinds on unregister */
+       if (user && !try_module_get(fb_helper->dev->driver->fops->owner))
                return -ENODEV;
 
        return 0;
@@ -3034,7 +3035,8 @@ static int drm_fbdev_fb_release(struct fb_info *info, int user)
 {
        struct drm_fb_helper *fb_helper = info->par;
 
-       module_put(fb_helper->dev->driver->fops->owner);
+       if (user)
+               module_put(fb_helper->dev->driver->fops->owner);
 
        return 0;
 }