kernel: Take devices into account in SharedMemory::free()

This commit is contained in:
apio 2023-08-03 09:33:10 +02:00
parent bfcca3a220
commit 641b65da0f
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -107,12 +107,16 @@ Result<void> SharedMemory::map(u64 virt, int flags, off_t _offset, usize count)
void SharedMemory::free()
{
if (inode && (prot & PROT_WRITE))
if ((inode || device) && (prot & PROT_WRITE))
{
for (u64 i = 0; i < frames.size(); i++)
{
inode->write((u8*)MMU::translate_physical_address(frames[i]), offset + (i * ARCH_PAGE_SIZE),
ARCH_PAGE_SIZE);
if (inode)
inode->write((u8*)MMU::translate_physical_address(frames[i]), offset + (i * ARCH_PAGE_SIZE),
ARCH_PAGE_SIZE);
if (device)
device->write((u8*)MMU::translate_physical_address(frames[i]), offset + (i * ARCH_PAGE_SIZE),
ARCH_PAGE_SIZE);
}
}