From 8601f74d5ffc7f675fe577d3849f6997f30005d6 Mon Sep 17 00:00:00 2001 From: Sahan Fernando Date: Fri, 18 Mar 2022 19:18:02 +1100 Subject: [PATCH] Kernel: Fix crash when opening GPU3DDevice without creating a context --- Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp | 3 +-- Kernel/Graphics/VirtIOGPU/GPU3DDevice.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp index c7b8e34cd9..c7740995bf 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp +++ b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp @@ -62,8 +62,7 @@ ErrorOr GPU3DDevice::ioctl(OpenFileDescription& description, unsigned requ // TODO: Delete the context if it fails to be set in m_context_state_lookup auto context_id = m_graphics_adapter.create_context(); RefPtr per_context_state = TRY(PerContextState::try_create(context_id)); - auto ref = RefPtr(description); - TRY(m_context_state_lookup.try_set(ref, per_context_state)); + TRY(m_context_state_lookup.try_set(&description, per_context_state)); return {}; } case VIRGL_IOCTL_TRANSFER_DATA: { diff --git a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h index a8a432355f..038d83e741 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h +++ b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h @@ -127,7 +127,7 @@ private: Kernel::Graphics::VirtIOGPU::GraphicsAdapter& m_graphics_adapter; // Context used for kernel operations (e.g. flushing resources to scanout) ContextID m_kernel_context_id; - HashMap, RefPtr> m_context_state_lookup; + HashMap> m_context_state_lookup; // Memory management for backing buffers OwnPtr m_transfer_buffer_region; constexpr static size_t NUM_TRANSFER_REGION_PAGES = 256;