diff --git a/src/backends/drm/drm_gbm_surface.cpp b/src/backends/drm/drm_gbm_surface.cpp index d8840fa862..ee69afa89c 100644 --- a/src/backends/drm/drm_gbm_surface.cpp +++ b/src/backends/drm/drm_gbm_surface.cpp @@ -134,6 +134,7 @@ std::variant, GbmSurface::Error> GbmSurface::createS EGLSurface eglSurface = eglCreatePlatformWindowSurfaceEXT(backend->eglDisplay(), config, surface, nullptr); if (eglSurface == EGL_NO_SURFACE) { qCCritical(KWIN_DRM) << "Creating EGL surface failed!" << getEglErrorString(); + gbm_surface_destroy(surface); return Error::Unknown; } return std::make_shared(backend, size, format, QVector{}, flags, surface, eglSurface); @@ -153,6 +154,7 @@ std::variant, GbmSurface::Error> GbmSurface::createS EGLSurface eglSurface = eglCreatePlatformWindowSurfaceEXT(backend->eglDisplay(), config, surface, nullptr); if (eglSurface == EGL_NO_SURFACE) { qCCritical(KWIN_DRM) << "Creating EGL surface failed!" << getEglErrorString(); + gbm_surface_destroy(surface); return Error::Unknown; } return std::make_shared(backend, size, format, modifiers, 0, surface, eglSurface);