mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:07:35 +00:00
Kernel: Make IPv4Socket::create API for SOCK_RAW OOM safe
This commit is contained in:
parent
46ce7adf7b
commit
858fff979a
1 changed files with 6 additions and 2 deletions
|
@ -44,8 +44,12 @@ KResultOr<NonnullRefPtr<Socket>> IPv4Socket::create(int type, int protocol)
|
||||||
}
|
}
|
||||||
if (type == SOCK_DGRAM)
|
if (type == SOCK_DGRAM)
|
||||||
return UDPSocket::create(protocol);
|
return UDPSocket::create(protocol);
|
||||||
if (type == SOCK_RAW)
|
if (type == SOCK_RAW) {
|
||||||
return adopt_ref(*new IPv4Socket(type, protocol));
|
auto raw_socket = adopt_ref_if_nonnull(new IPv4Socket(type, protocol));
|
||||||
|
if (raw_socket)
|
||||||
|
return raw_socket.release_nonnull();
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue