LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] drm: udl: Destroy framebuffer only if it was initialized
@ 2018-04-20 11:50 Emil Lundmark
  2018-04-20 13:55 ` Sean Paul
  2018-05-28 14:27 ` [PATCH v2] " Emil Lundmark
  0 siblings, 2 replies; 8+ messages in thread
From: Emil Lundmark @ 2018-04-20 11:50 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Sean Paul, linux-kernel, Emil Lundmark

This fixes a NULL pointer dereference that can happen if the UDL
driver is unloaded before the framebuffer is initialized. This can
happen e.g. if the USB device is unplugged right after it was plugged
in.

Signed-off-by: Emil Lundmark <lndmrk@chromium.org>
---
 drivers/gpu/drm/udl/udl_fb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index 2ebdc6d5a76e..5754e37f741b 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -426,9 +426,11 @@ static void udl_fbdev_destroy(struct drm_device *dev,
 {
 	drm_fb_helper_unregister_fbi(&ufbdev->helper);
 	drm_fb_helper_fini(&ufbdev->helper);
-	drm_framebuffer_unregister_private(&ufbdev->ufb.base);
-	drm_framebuffer_cleanup(&ufbdev->ufb.base);
-	drm_gem_object_put_unlocked(&ufbdev->ufb.obj->base);
+	if (ufbdev->ufb.obj) {
+		drm_framebuffer_unregister_private(&ufbdev->ufb.base);
+		drm_framebuffer_cleanup(&ufbdev->ufb.base);
+		drm_gem_object_put_unlocked(&ufbdev->ufb.obj->base);
+	}
 }
 
 int udl_fbdev_init(struct drm_device *dev)
-- 
2.17.0.484.g0c8726318c-goog

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-09-10 14:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 11:50 [PATCH] drm: udl: Destroy framebuffer only if it was initialized Emil Lundmark
2018-04-20 13:55 ` Sean Paul
2018-04-24 13:04   ` Daniel Vetter
2018-04-25 22:56     ` Stéphane Marchesin
2018-04-26  9:50       ` Daniel Vetter
2018-05-28 14:27 ` [PATCH v2] " Emil Lundmark
2018-05-29  6:46   ` Daniel Vetter
2018-09-10 14:23   ` Sean Paul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).