drm/crtc_helper: Reset empty plane state in drm_helper_crtc_mode_set_base()
authorLiu Ying <gnuiyl@gmail.com>
Tue, 5 Apr 2016 08:50:39 +0000 (16:50 +0800)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 14 Apr 2016 06:18:15 +0000 (08:18 +0200)
Transitional drivers might access the NULL pointer plane->state in
drm_helper_crtc_mode_set_base(), which causes NULL pointer dereference.
So, let's reset it before handing it over to those drivers.
commit e4f31ad2b713 ("drm: reset empty state in transitional helpers")
did the same thing for other transitional helpers, but it seems this one
was missed.

Signed-off-by: Liu Ying <gnuiyl@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1459846239-8946-1-git-send-email-gnuiyl@gmail.com
drivers/gpu/drm/drm_crtc_helper.c

index 79555d2b1b87c2760a241f34d7f7661ff808280c..66ca31348546cd86e4013f298d504777103883fb 100644 (file)
@@ -1053,10 +1053,12 @@ int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
 
        if (plane->funcs->atomic_duplicate_state)
                plane_state = plane->funcs->atomic_duplicate_state(plane);
-       else if (plane->state)
+       else {
+               if (!plane->state)
+                       drm_atomic_helper_plane_reset(plane);
+
                plane_state = drm_atomic_helper_plane_duplicate_state(plane);
-       else
-               plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
+       }
        if (!plane_state)
                return -ENOMEM;
        plane_state->plane = plane;