mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
Kernel: Return ENOMEM in more places
There are plenty of places in the kernel that aren't checking if they actually got their allocation. This fixes some of them, but definitely not all. Fixes #3390 Fixes #3391 Also, let's make find_one_free_page() return nullptr if it doesn't get a free index. This stops the kernel crashing when out of memory and allows memory purging to take place again. Fixes #3487
This commit is contained in:
parent
2229b13c97
commit
68b361bd21
9 changed files with 34 additions and 12 deletions
|
@ -235,8 +235,12 @@ KResultOr<size_t> SB16::write(FileDescription&, size_t, const UserOrKernelBuffer
|
|||
{
|
||||
if (!m_dma_region) {
|
||||
auto page = MM.allocate_supervisor_physical_page();
|
||||
if (!page)
|
||||
return KResult(-ENOMEM);
|
||||
auto vmobject = AnonymousVMObject::create_with_physical_page(*page);
|
||||
m_dma_region = MM.allocate_kernel_region_with_vmobject(*vmobject, PAGE_SIZE, "SB16 DMA buffer", Region::Access::Write);
|
||||
if (!m_dma_region)
|
||||
return KResult(-ENOMEM);
|
||||
}
|
||||
|
||||
#ifdef SB16_DEBUG
|
||||
|
@ -245,7 +249,7 @@ KResultOr<size_t> SB16::write(FileDescription&, size_t, const UserOrKernelBuffer
|
|||
ASSERT(length <= PAGE_SIZE);
|
||||
const int BLOCK_SIZE = 32 * 1024;
|
||||
if (length > BLOCK_SIZE) {
|
||||
return -ENOSPC;
|
||||
return KResult(-ENOSPC);
|
||||
}
|
||||
|
||||
u8 mode = (u8)SampleFormat::Signed | (u8)SampleFormat::Stereo;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue