diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index 03744241a7..4abf968154 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -647,7 +647,14 @@ std::shared_ptr DrmBackend::createDmaBufTexture(const QSize &size gbm_bo_destroy(bo); const auto eglBackend = static_cast(m_renderBackend); eglBackend->makeCurrent(); - return std::make_shared(eglBackend->importDmaBufAsTexture(attributes), attributes); + if (auto texture = eglBackend->importDmaBufAsTexture(attributes)) { + return std::make_shared(texture, attributes); + } else { + for (int i = 0; i < attributes.planeCount; ++i) { + ::close(attributes.fd[i]); + } + return nullptr; + } } DrmGpu *DrmBackend::primaryGpu() const