From d76e678da29df7bca7bfe025380b5da65e1118a9 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 12 Mar 2022 13:35:30 -0800 Subject: [PATCH] fs: fix missing mutex acquire in compressed storage invalidate/find --- .../fssystem/fssystem_compressed_storage.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp index 749ddec81..8922cd0d6 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp @@ -893,6 +893,10 @@ namespace ams::fssystem { } void Invalidate() { + /* Acquire exclusive access to our manager. */ + std::scoped_lock lk(m_mutex); + + /* Invalidate all entries. */ return m_block_cache_manager.Invalidate(); } @@ -1095,11 +1099,17 @@ namespace ams::fssystem { AMS_ASSERT(out != nullptr); AMS_ASSERT(out_entry != nullptr); + /* Acquire exclusive access to our entries. */ + std::scoped_lock lk(m_mutex); + /* Find the buffer. */ R_RETURN(this->FindBufferImpl(out, out_entry, offset)); } Result FindBufferImpl(fs::IBufferManager::MemoryRange *out, CacheEntry *out_entry, s64 offset) { + /* Check pre-conditions. */ + AMS_ASSERT(m_mutex.IsLockedByCurrentThread()); + /* Get our block cache count */ const auto count = m_block_cache_manager.GetCount();