From 36f2e8582395dffe33739951ef4e8b79b78f813d Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 23 Sep 2022 15:59:53 +0300 Subject: [PATCH] WindowServer: Fix mapping the correct framebuffer size If we don't support double buffering for a certain type of hardware, don't try to map with size calculated with (pitch * height * 2), as it will result in trying to map more memory than is available in the framebuffer memory range. --- Userland/Services/WindowServer/HardwareScreenBackend.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Services/WindowServer/HardwareScreenBackend.cpp b/Userland/Services/WindowServer/HardwareScreenBackend.cpp index ce6f88bd2d4..9c9a82b60e6 100644 --- a/Userland/Services/WindowServer/HardwareScreenBackend.cpp +++ b/Userland/Services/WindowServer/HardwareScreenBackend.cpp @@ -85,7 +85,11 @@ ErrorOr HardwareScreenBackend::map_framebuffer() if (rc != 0) { return Error::from_syscall("graphics_connector_get_head_mode_setting"sv, rc); } - m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active * 2; + if (m_can_set_head_buffer) { + m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active * 2; + } else { + m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active; + } m_framebuffer = (Gfx::ARGB32*)TRY(Core::System::mmap(nullptr, m_size_in_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, m_display_connector_fd, 0)); if (m_can_set_head_buffer) {