platform_drv: fix uncaught exception

Calling alloc_dma_buffer() with size=0 will cause an exception in the
ram allocator.

genodelabs/genode#4518
This commit is contained in:
Johannes Schlatow 2022-05-24 13:56:11 +02:00 committed by Christian Helmuth
parent df5cadc8ad
commit 3b0995cb49

View File

@ -177,7 +177,11 @@ void Session_component::release_device(Capability<Platform::Device_interface> de
Genode::Ram_dataspace_capability
Session_component::alloc_dma_buffer(size_t const size, Cache cache)
{
Ram_dataspace_capability ram_cap = _env_ram.alloc(size, cache);
Ram_dataspace_capability ram_cap { };
try {
ram_cap = _env_ram.alloc(size, cache);
} catch (Ram_allocator::Denied) { }
if (!ram_cap.valid()) return ram_cap;