From 97e740c9865006384395c5cb31394bb0cc194475 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 12 May 2022 17:12:24 +0100 Subject: [PATCH] Fix slight locking bug with nvmap handle duplication --- app/src/main/cpp/skyline/services/nvdrv/core/nvmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/cpp/skyline/services/nvdrv/core/nvmap.cpp b/app/src/main/cpp/skyline/services/nvdrv/core/nvmap.cpp index 214f40f6..47286b7c 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/core/nvmap.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/core/nvmap.cpp @@ -40,12 +40,12 @@ namespace skyline::service::nvdrv::core { } PosixResult NvMap::Handle::Duplicate(bool internalSession) { + std::scoped_lock lock(mutex); + // Unallocated handles cannot be duplicated as duplication requires memory accounting (in HOS) if (!allocated) [[unlikely]] return PosixResult::InvalidArgument; - std::scoped_lock lock(mutex); - // If we internally use FromId the duplication tracking of handles won't work accurately due to us not implementing // per-process handle refs. if (internalSession)