Kernel: Release packet buffer in TCPSocket::send_tcp_packet

Previously we wouldn't release the buffer back to the network adapter
in all cases. While this didn't leak the buffer it would cause the
buffer to not be reused for other packets.
This commit is contained in:
Gunnar Beutner 2021-05-28 00:49:53 +02:00 committed by Andreas Kling
parent 547eb4973a
commit 3fc75088a2
Notes: sideshowbarker 2024-07-18 17:17:03 +09:00

View File

@ -220,8 +220,10 @@ KResult TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload,
tcp_packet.set_ack_number(m_ack_number);
}
if (payload && !payload->read(tcp_packet.payload(), payload_size))
if (payload && !payload->read(tcp_packet.payload(), payload_size)) {
routing_decision.adapter->release_packet_buffer(*packet);
return EFAULT;
}
if (flags & TCPFlags::SYN) {
++m_sequence_number;
@ -247,6 +249,8 @@ KResult TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload,
m_not_acked.append({ m_sequence_number, move(packet), ipv4_payload_offset, *routing_decision.adapter });
m_not_acked_size += payload_size;
enqueue_for_retransmit();
} else {
routing_decision.adapter->release_packet_buffer(*packet);
}
return KSuccess;