diff --git a/repos/dde_linux/src/lib/usb/include/usb_nic_component.h b/repos/dde_linux/src/lib/usb/include/usb_nic_component.h index 84f3ce1251..fd1da5973d 100644 --- a/repos/dde_linux/src/lib/usb/include/usb_nic_component.h +++ b/repos/dde_linux/src/lib/usb/include/usb_nic_component.h @@ -242,12 +242,10 @@ class Root : public Root_component /* * Check if donated ram quota suffices for both communication - * buffers. Also check both sizes separately to handle a - * possible overflow of the sum of both sizes. + * buffers and check for overflow */ - if (tx_buf_size > ram_quota - session_size - || rx_buf_size > ram_quota - session_size - || tx_buf_size + rx_buf_size > ram_quota - session_size) { + if (tx_buf_size + rx_buf_size < tx_buf_size || + tx_buf_size + rx_buf_size > ram_quota - session_size) { PERR("insufficient 'ram_quota', got %zd, need %zd", ram_quota, tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded(); diff --git a/repos/dde_linux/src/lib/wifi/nic.cc b/repos/dde_linux/src/lib/wifi/nic.cc index 27bc5f5f31..57d481607a 100644 --- a/repos/dde_linux/src/lib/wifi/nic.cc +++ b/repos/dde_linux/src/lib/wifi/nic.cc @@ -203,12 +203,10 @@ class Root : public Genode::Root_component ram_quota - session_size - || rx_buf_size > ram_quota - session_size - || tx_buf_size + rx_buf_size > ram_quota - session_size) { + if (tx_buf_size + rx_buf_size < tx_buf_size || + tx_buf_size + rx_buf_size > ram_quota - session_size) { PERR("insufficient 'ram_quota', got %zd, need %zd", ram_quota, tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded(); diff --git a/repos/os/include/nic/root.h b/repos/os/include/nic/root.h index 7417170872..9993ee06b7 100644 --- a/repos/os/include/nic/root.h +++ b/repos/os/include/nic/root.h @@ -48,12 +48,10 @@ class Nic::Root : public Genode::Root_component ram_quota - session_size - || rx_buf_size > ram_quota - session_size - || tx_buf_size + rx_buf_size > ram_quota - session_size) { + if (tx_buf_size + rx_buf_size < tx_buf_size || + tx_buf_size + rx_buf_size > ram_quota - session_size) { PERR("insufficient 'ram_quota', got %zd, need %zd", ram_quota, tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded(); diff --git a/repos/os/src/drivers/nic/spec/lan9118/main.cc b/repos/os/src/drivers/nic/spec/lan9118/main.cc index 2099cbb081..2a5c428edf 100644 --- a/repos/os/src/drivers/nic/spec/lan9118/main.cc +++ b/repos/os/src/drivers/nic/spec/lan9118/main.cc @@ -52,12 +52,10 @@ class Root : public Genode::Root_component /* * Check if donated ram quota suffices for both communication - * buffers. Also check both sizes separately to handle a - * possible overflow of the sum of both sizes. + * buffers and check for overflow */ - if (tx_buf_size > ram_quota - session_size - || rx_buf_size > ram_quota - session_size - || tx_buf_size + rx_buf_size > ram_quota - session_size) { + if (tx_buf_size + rx_buf_size < tx_buf_size || + tx_buf_size + rx_buf_size > ram_quota - session_size) { PERR("insufficient 'ram_quota', got %zd, need %zd", ram_quota, tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded(); diff --git a/repos/os/src/server/nic_loopback/main.cc b/repos/os/src/server/nic_loopback/main.cc index 0e1a377947..e134ceec6c 100644 --- a/repos/os/src/server/nic_loopback/main.cc +++ b/repos/os/src/server/nic_loopback/main.cc @@ -166,12 +166,10 @@ class Nic::Root : public Genode::Root_component /* * Check if donated ram quota suffices for both communication - * buffers. Also check both sizes separately to handle a - * possible overflow of the sum of both sizes. + * buffers and check for overflow */ - if (tx_buf_size > ram_quota - session_size - || rx_buf_size > ram_quota - session_size - || tx_buf_size + rx_buf_size > ram_quota - session_size) { + if (tx_buf_size + rx_buf_size < tx_buf_size || + tx_buf_size + rx_buf_size > ram_quota - session_size) { PERR("insufficient 'ram_quota', got %zd, need %zd", ram_quota, tx_buf_size + rx_buf_size + session_size); throw Root::Quota_exceeded(); diff --git a/repos/ports/src/app/openvpn/main.cc b/repos/ports/src/app/openvpn/main.cc index c7852918a0..aeb03e02a3 100644 --- a/repos/ports/src/app/openvpn/main.cc +++ b/repos/ports/src/app/openvpn/main.cc @@ -230,12 +230,10 @@ class Root : public Genode::Root_component ram_quota - session_size - || rx_buf_size > ram_quota - session_size - || tx_buf_size + rx_buf_size > ram_quota - session_size) { + if (tx_buf_size + rx_buf_size < tx_buf_size || + tx_buf_size + rx_buf_size > ram_quota - session_size) { PERR("insufficient 'ram_quota', got %zd, need %zd", ram_quota, tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded();