Skip to content

Commit

Permalink
Kernel: Fix crash when opening GPU3DDevice without creating a context
Browse files Browse the repository at this point in the history
  • Loading branch information
ccapitalK authored and alimpfard committed Mar 18, 2022
1 parent 3bbb573 commit 8601f74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ ErrorOr<void> 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<PerContextState> 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: {
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Graphics/VirtIOGPU/GPU3DDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class GPU3DDevice : public CharacterDevice {
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<OpenFileDescription>, RefPtr<PerContextState>> m_context_state_lookup;
HashMap<OpenFileDescription*, RefPtr<PerContextState>> m_context_state_lookup;
// Memory management for backing buffers
OwnPtr<Memory::Region> m_transfer_buffer_region;
constexpr static size_t NUM_TRANSFER_REGION_PAGES = 256;
Expand Down

0 comments on commit 8601f74

Please sign in to comment.