diff --git a/repos/os/src/drivers/platform/session_component.cc b/repos/os/src/drivers/platform/session_component.cc index 081ab14ed1..68168094fe 100644 --- a/repos/os/src/drivers/platform/session_component.cc +++ b/repos/os/src/drivers/platform/session_component.cc @@ -176,6 +176,19 @@ Session_component::alloc_dma_buffer(size_t const size, Cache cache) { Ram_dataspace_capability ram_cap { }; + /* + * Check available quota beforehand and reflect the state back + * to the client because the 'Expanding_pd_session_client' will + * ask its parent otherwise. + */ + enum { WATERMARK_CAP_QUOTA = 8, }; + if (_env.pd().avail_caps().value < WATERMARK_CAP_QUOTA) + throw Out_of_caps(); + + enum { WATERMARK_RAM_QUOTA = 4096, }; + if (_env.pd().avail_ram().value < WATERMARK_RAM_QUOTA) + throw Out_of_ram(); + try { ram_cap = _env_ram.alloc(size, cache); } catch (Ram_allocator::Denied) { }