radeon: Only destroy fbdev framebuffer if it was initialized
authorMichel Dänzer <michel.daenzer@amd.com>
Mon, 11 Sep 2017 08:09:17 +0000 (17:09 +0900)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 13 Sep 2017 16:10:12 +0000 (12:10 -0400)
Fixes crash when trying to unload the radeon module before the fbdev
framebuffer was initialized, which can happen since the DRM fbdev helper
code supports deferred setup.

Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_fb.c

index fd25361ac681bb3507a9c0f168a16c83b7724855..2fcf805d3a169e9776634fc4f5ddfcbd4b9fbee7 100644 (file)
@@ -322,10 +322,10 @@ static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfb
        if (rfb->obj) {
                radeonfb_destroy_pinned_object(rfb->obj);
                rfb->obj = NULL;
+               drm_framebuffer_unregister_private(&rfb->base);
+               drm_framebuffer_cleanup(&rfb->base);
        }
        drm_fb_helper_fini(&rfbdev->helper);
-       drm_framebuffer_unregister_private(&rfb->base);
-       drm_framebuffer_cleanup(&rfb->base);
 
        return 0;
 }