diff --git a/kernel/src/fs/devices/FramebufferDevice.cpp b/kernel/src/fs/devices/FramebufferDevice.cpp index 3b82f095..39f19f44 100644 --- a/kernel/src/fs/devices/FramebufferDevice.cpp +++ b/kernel/src/fs/devices/FramebufferDevice.cpp @@ -39,6 +39,11 @@ Result FramebufferDevice::query_shared_memory(off_t offset, usize count) } auto* shm = g_shared_memory_map.try_get_ref(*m_shmid); + if (!shm) + { + m_shmid = {}; + return query_shared_memory(offset, count); + } if (shm->offset > offset) { TRY(shm->grow_backward(Framebuffer::ptr() + offset, (shm->offset - offset) / ARCH_PAGE_SIZE)); diff --git a/kernel/src/fs/tmpfs/Inode.cpp b/kernel/src/fs/tmpfs/Inode.cpp index 252054fa..08ec9df7 100644 --- a/kernel/src/fs/tmpfs/Inode.cpp +++ b/kernel/src/fs/tmpfs/Inode.cpp @@ -144,6 +144,12 @@ namespace TmpFS } auto* shm = g_shared_memory_map.try_get_ref(*m_shmid); + if (!shm) + { + m_shmid = {}; + return query_shared_memory(offset, count); + } + if (shm->offset > offset) { TRY(shm->grow_backward(m_data_buffer.data() + offset, (shm->offset - offset) / ARCH_PAGE_SIZE));