1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

Kernel: Handle OOM when allocating Packet KBuffers

This commit is contained in:
Brian Gianforcaro 2021-08-01 05:11:49 -07:00 committed by Andreas Kling
parent 8c4785bd10
commit 720a686a76
6 changed files with 47 additions and 38 deletions

View file

@ -241,11 +241,11 @@ KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer&
return ENOMEM;
routing_decision.adapter->fill_in_ipv4_header(*packet, local_address(), routing_decision.next_hop,
m_peer_address, (IPv4Protocol)protocol(), data_length, m_ttl);
if (!data.read(packet->buffer.data() + ipv4_payload_offset, data_length)) {
if (!data.read(packet->buffer->data() + ipv4_payload_offset, data_length)) {
routing_decision.adapter->release_packet_buffer(*packet);
return EFAULT;
}
routing_decision.adapter->send_packet({ packet->buffer.data(), packet->buffer.size() });
routing_decision.adapter->send_packet(packet->bytes());
routing_decision.adapter->release_packet_buffer(*packet);
return data_length;
}