diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 4d9476b6e6..bd2b081129 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -1623,12 +1623,18 @@ RefPtr Ext2FSInode::lookup(StringView name) dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): Looking up '{}'", identifier(), name); if (populate_lookup_cache().is_error()) return {}; - Locker locker(m_lock); - auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; }); - if (it != m_lookup_cache.end()) - return fs().get_inode({ fsid(), (*it).value }); - dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): '{}' not found", identifier(), name); - return {}; + + InodeIndex inode_index; + { + Locker locker(m_lock); + auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; }); + if (it == m_lookup_cache.end()) { + dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): '{}' not found", identifier(), name); + return {}; + } + inode_index = it->value; + } + return fs().get_inode({ fsid(), inode_index }); } void Ext2FSInode::one_ref_left()