drm: Reject fbs w/o format info in drm_framebuffer_init()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 18 Nov 2016 19:52:58 +0000 (21:52 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 15 Dec 2016 12:55:30 +0000 (14:55 +0200)
Any framebuffer that doesn't have proper format information when
drm_framebuffer_init() is called is a bug. Let's warn and return
an error to avoid oopsing the kernel later due to dereferencing the
NULL fb->format pointer.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1479498793-31021-23-git-send-email-ville.syrjala@linux.intel.com
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/gpu/drm/drm_framebuffer.c

index f397565d3c20160f3fc6c8a647edfdd72df19645..892976d974e51ea10bfdb9e812bca1454f9db0e6 100644 (file)
@@ -631,7 +631,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
 {
        int ret;
 
-       if (WARN_ON_ONCE(fb->dev != dev))
+       if (WARN_ON_ONCE(fb->dev != dev || !fb->format))
                return -EINVAL;
 
        INIT_LIST_HEAD(&fb->filp_head);