mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-05 02:33:03 +00:00
Kernel: Initialize DiskCache's buffer before the dirty&clean lists
This commit fixes a kernel panic that happened when unmounting a disk due to an invalid memory access. This was because `DiskCache` initializes two linked lists that use an argument `KBuffer` as the storage for their elements. Since the member `KBuffer` was declared after the two lists, when `DiskCache`'s destructor was called, then `KBuffer`'s destructor was called before the ones of the two lists, causing a page fault in the kernel.
This commit is contained in:
parent
7375beced3
commit
1b04c43690
Notes:
sideshowbarker
2024-07-17 09:56:35 +09:00
Author: https://github.com/mrkct
Commit: 1b04c43690
Pull-request: https://github.com/SerenityOS/serenity/pull/18139
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/supercomputer7 ✅
1 changed files with 5 additions and 2 deletions
|
@ -101,11 +101,14 @@ public:
|
|||
|
||||
private:
|
||||
mutable NonnullRefPtr<BlockBasedFileSystem> m_fs;
|
||||
NonnullOwnPtr<KBuffer> m_cached_block_data;
|
||||
|
||||
// NOTE: m_entries must be declared before m_dirty_list and m_clean_list because their entries are allocated from it.
|
||||
// We need to ensure that the destructors of m_dirty_list and m_clean_list are called before m_entries is destroyed.
|
||||
NonnullOwnPtr<KBuffer> m_entries;
|
||||
mutable IntrusiveList<&CacheEntry::list_node> m_dirty_list;
|
||||
mutable IntrusiveList<&CacheEntry::list_node> m_clean_list;
|
||||
mutable HashMap<BlockBasedFileSystem::BlockIndex, CacheEntry*> m_hash;
|
||||
NonnullOwnPtr<KBuffer> m_cached_block_data;
|
||||
NonnullOwnPtr<KBuffer> m_entries;
|
||||
};
|
||||
|
||||
BlockBasedFileSystem::BlockBasedFileSystem(OpenFileDescription& file_description)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue