Kernel: Don't update write_pos in DoubleBuffer if userspace copy fails

This commit is contained in:
Sahan Fernando 2021-05-13 12:19:53 +10:00 committed by Andreas Kling
parent c3b670c092
commit 63a1be1406
Notes: sideshowbarker 2024-07-18 17:50:38 +09:00

View File

@ -47,10 +47,10 @@ ssize_t DoubleBuffer::write(const UserOrKernelBuffer& data, size_t size)
Locker locker(m_lock);
size_t bytes_to_write = min(size, m_space_for_writing);
u8* write_ptr = m_write_buffer->data + m_write_buffer->size;
m_write_buffer->size += bytes_to_write;
compute_lockfree_metadata();
if (!data.read(write_ptr, bytes_to_write))
return -EFAULT;
m_write_buffer->size += bytes_to_write;
compute_lockfree_metadata();
if (m_unblock_callback && !m_empty)
m_unblock_callback();
return (ssize_t)bytes_to_write;