diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2019-03-06 11:12:47 +0100 |
---|---|---|
committer | Philipp Zabel <philipp.zabel@gmail.com> | 2019-03-06 11:26:42 +0100 |
commit | 5c8eef147c27a95ebb8ba79e19ebb190b025cbe0 (patch) | |
tree | c5996dc2c131f8ed6d75b4839c33fe7d58ab20a5 | |
parent | 2293cb42384e0297e53fb876697342528926a710 (diff) | |
download | weston-5c8eef147c27a95ebb8ba79e19ebb190b025cbe0.tar.gz |
compositor-drm: clear gbm_surface pointer after destroying the GBM surface
Since commit ee1d968e641e ("compositor-drm: Fall back if GBM surface fails with
modifiers"), drm_output_init_egl requires output->gbm_surface to be NULL, or
gbm_surface_create will not be called if HAVE_GBM_MODIFIERS is enabled but no
modifiers are supported by the plane. This could happen if _init_egl is called
after drm_ouptut_fini_egl drom drm_output_switch_mode.
Add an assert to guarantee the requirement and clears the gbm_surface pointer
after the surface is destroyed.
Signed-off-by: Philipp Zabel <p.pzabel@pengutronix.de>
-rw-r--r-- | libweston/compositor-drm.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 905a0869..c1101105 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -5045,6 +5045,8 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b) struct drm_plane *plane = output->scanout_plane; unsigned int i; + assert(output->gbm_surface == NULL); + for (i = 0; i < plane->count_formats; i++) { if (plane->formats[i].format == output->gbm_format) break; @@ -5094,6 +5096,7 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b) n_formats) < 0) { weston_log("failed to create gl renderer output state\n"); gbm_surface_destroy(output->gbm_surface); + output->gbm_surface = NULL; return -1; } @@ -5120,6 +5123,7 @@ drm_output_fini_egl(struct drm_output *output) gl_renderer->output_destroy(&output->base); gbm_surface_destroy(output->gbm_surface); + output->gbm_surface = NULL; drm_output_fini_cursor_egl(output); } |