From f77ddf64f8533aad6fb4a9a4d7b213967a0f54a8 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Tue, 15 Oct 2024 18:49:08 +1100 Subject: [PATCH] platforms/atomic-kms: Fail gracefully when bypass buffer can't be imported for scanout. The compositor code is expecting `framebuffer_for` to sometimes return `nullptr`; this is fine. What's *not* fine is passing a null `fb_id` to `AtomicKmsFbHandle` and then returning a *non*-null `Framebuffer` that's broken :) --- src/platforms/atomic-kms/server/kms/display_buffer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platforms/atomic-kms/server/kms/display_buffer.cpp b/src/platforms/atomic-kms/server/kms/display_buffer.cpp index 0b7371d3e1..902c8c71ee 100644 --- a/src/platforms/atomic-kms/server/kms/display_buffer.cpp +++ b/src/platforms/atomic-kms/server/kms/display_buffer.cpp @@ -442,6 +442,11 @@ auto mga::DmaBufDisplayAllocator::framebuffer_for(std::shared_ptr { auto fb_id = drm_fb_id_from_dma_buffer(drm_fd(), gbm, buffer); + if (!fb_id) + { + return {}; + } + struct AtomicKmsFbHandle : public mg::FBHandle { AtomicKmsFbHandle(std::shared_ptr fb_handle, geometry::Size size) :