From ba6b22f16085b52c65fa5efea0859382cfb14d12 Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Thu, 6 Aug 2026 18:48:23 +0200 Subject: [PATCH] Simplify device map locking using RAII --- xtoskrnl/ob/devmap.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/xtoskrnl/ob/devmap.cc b/xtoskrnl/ob/devmap.cc index 143036b17..47d751b3e 100644 --- a/xtoskrnl/ob/devmap.cc +++ b/xtoskrnl/ob/devmap.cc @@ -28,8 +28,9 @@ OB::DeviceMap::GetGlobalDevicesDirectory(IN POBJECT_DIRECTORY Directory) /* Assume no mapping exists */ GlobalDevicesDirectory = NULLPTR; - /* Acquire the device map lock */ - KE::PushLock::AcquireExclusivePushLock(&DeviceMapLock); + /* Enter guarded region and acquire the device map lock */ + KE::GuardedRegionGuard GuardedRegion; + KE::PushLockExclusiveGuard PushLock(&DeviceMapLock); /* Check if the directory has an associated device map */ if(Directory->DeviceMap) @@ -38,9 +39,6 @@ OB::DeviceMap::GetGlobalDevicesDirectory(IN POBJECT_DIRECTORY Directory) GlobalDevicesDirectory = Directory->DeviceMap->GlobalDevicesDirectory; } - /* Release the device map lock */ - KE::PushLock::ReleaseExclusivePushLock(&DeviceMapLock); - /* Return the resolved directory */ return GlobalDevicesDirectory; }