From 80a84bef26fd9d03c25c19cd712327c732b836d7 Mon Sep 17 00:00:00 2001 From: Piotr Tworek Date: Sat, 5 Oct 2019 22:05:38 +0200 Subject: [PATCH] Fix ram session quota accounting in lan9118 This driver manually checks if the RAM quota is big enough for the Lan9118 nic session component. The problem is Root_component::_create from which Root_component::_create_session gets called does already check this. No need to account for it twice. Fixes #3514 --- repos/os/src/drivers/nic/lan9118/main.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/repos/os/src/drivers/nic/lan9118/main.cc b/repos/os/src/drivers/nic/lan9118/main.cc index ee1bfc1f6..91a4d9cec 100644 --- a/repos/os/src/drivers/nic/lan9118/main.cc +++ b/repos/os/src/drivers/nic/lan9118/main.cc @@ -63,19 +63,14 @@ class Root : public Genode::Root_component size_t tx_buf_size = Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); size_t rx_buf_size = Arg_string::find_arg(args, "rx_buf_size").ulong_value(0); - /* deplete ram quota by the memory needed for the session structure */ - size_t session_size = max(4096UL, (unsigned long)sizeof(Lan9118)); - if (ram_quota < session_size) - throw Genode::Insufficient_ram_quota(); - /* * Check if donated ram quota suffices for both communication * buffers and check for overflow */ if (tx_buf_size + rx_buf_size < tx_buf_size || - tx_buf_size + rx_buf_size > ram_quota - session_size) { + tx_buf_size + rx_buf_size > ram_quota) { error("insufficient 'ram_quota', got ", ram_quota, ", " - "need ", tx_buf_size + rx_buf_size + session_size); + "need ", tx_buf_size + rx_buf_size); throw Genode::Insufficient_ram_quota(); }