drm: change timing to set color format for primary plane without universal plane
authorTomohito Esaki <etom@igel.co.jp>
Mon, 30 Mar 2020 08:10:54 +0000 (17:10 +0900)
committerTomohito Esaki <etom@igel.co.jp>
Mon, 30 Mar 2020 08:43:20 +0000 (17:43 +0900)
Without universal plane, the weston crashes with null pointer access in
set_gbm_format function because that function called before output
enable function. By changing timing to set color format for primary
plane in this case, this issue fixes.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
libweston/backend-drm/drm.c

index 3c5ca65a943ab5e233e16e9f5893187678ca2ee1..2aea82f55444e05e3e97c986bd250ea3f92c2d83 100644 (file)
@@ -1389,12 +1389,6 @@ drm_output_set_gbm_format(struct weston_output *base,
 
        if (parse_gbm_format(gbm_format, b->gbm_format, &output->gbm_format) == -1)
                output->gbm_format = b->gbm_format;
-
-       /* Without universal planes, we can't discover which formats are
-        * supported by the primary plane; we just hope that the GBM format
-        * works. */
-       if (!b->universal_planes)
-               output->scanout_plane->formats[0].format = output->gbm_format;
 }
 
 static void
@@ -1626,6 +1620,12 @@ drm_output_init_crtc(struct drm_output *output, drmModeRes *resources)
                goto err_crtc;
        }
 
+       /* Without universal planes, we can't discover which formats are
+        * supported by the primary plane; we just hope that the GBM format
+        * works. */
+       if (!b->universal_planes)
+               output->scanout_plane->formats[0].format = output->gbm_format;
+
        /* Failing to find a cursor plane is not fatal, as we'll fall back
         * to software cursor. */
        output->cursor_plane =