diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 35b8ea2028..5b366db8dc 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,8 @@ static bool send(InterfaceDescriptor const& iface, DHCPv4Packet const& packet, C return false; } + ScopeGuard socket_close_guard = [&] { close(fd); }; + if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, iface.ifname.characters(), IFNAMSIZ) < 0) { dbgln("ERROR: setsockopt(SO_BINDTODEVICE) :: {}", strerror(errno)); return false;