summaryrefslogtreecommitdiff
path: root/Kernel/Bus
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-04 12:45:17 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-04 13:08:37 +0200
commitb02eb8224cd45d6b5c2257bc96b2d59451566906 (patch)
tree08c5b76f02c1b84552d272193356931a8d40b5d1 /Kernel/Bus
parent791309a3d2eae208ba263a0f4482170e5ddd4a1c (diff)
downloadserenity-b02eb8224cd45d6b5c2257bc96b2d59451566906.zip
Kernel/VirtIO: Add two missing error checks in VirtIO::ConsolePort
Diffstat (limited to 'Kernel/Bus')
-rw-r--r--Kernel/Bus/VirtIO/ConsolePort.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/Kernel/Bus/VirtIO/ConsolePort.cpp b/Kernel/Bus/VirtIO/ConsolePort.cpp
index d9e9cb92c9..853a819369 100644
--- a/Kernel/Bus/VirtIO/ConsolePort.cpp
+++ b/Kernel/Bus/VirtIO/ConsolePort.cpp
@@ -47,7 +47,11 @@ void ConsolePort::handle_queue_update(Badge<VirtIO::Console>, u16 queue_index)
QueueChain popped_chain = queue.pop_used_buffer_chain(used);
SpinlockLocker ringbuffer_lock(m_receive_buffer->lock());
- auto used_space = m_receive_buffer->reserve_space(used).value();
+ auto used_space_or_error = m_receive_buffer->reserve_space(used);
+ if (used_space_or_error.is_error()) {
+ TODO();
+ }
+ auto used_space = used_space_or_error.release_value();
auto remaining_space = m_receive_buffer->bytes_till_end();
// Our algorithm always has only one buffer in the queue.
@@ -97,7 +101,10 @@ KResultOr<size_t> ConsolePort::read(FileDescription& desc, u64, UserOrKernelBuff
if (!can_read(desc, size))
return EAGAIN;
- auto bytes_copied = m_receive_buffer->copy_data_out(size, buffer).value();
+ auto bytes_copied_or_error = m_receive_buffer->copy_data_out(size, buffer);
+ if (bytes_copied_or_error.is_error())
+ return bytes_copied_or_error.error();
+ auto bytes_copied = bytes_copied_or_error.release_value();
m_receive_buffer->reclaim_space(m_receive_buffer->start_of_used(), bytes_copied);
if (m_receive_buffer_exhausted && m_receive_buffer->used_bytes() == 0) {