n-acd: fix leaking socket handle in n_acd_socket_new() when setsockopt() fails

Found by Coverity.
This commit is contained in:
Thomas Haller
2019-08-02 11:26:25 +02:00
parent d3bd7b9bee
commit c8cee413dd

View File

@@ -127,8 +127,10 @@ static int n_acd_socket_new(int *fdp, int fd_bpf_prog, NAcdConfig *config) {
if (fd_bpf_prog >= 0) { if (fd_bpf_prog >= 0) {
r = setsockopt(s, SOL_SOCKET, SO_ATTACH_BPF, &fd_bpf_prog, sizeof(fd_bpf_prog)); r = setsockopt(s, SOL_SOCKET, SO_ATTACH_BPF, &fd_bpf_prog, sizeof(fd_bpf_prog));
if (r < 0) if (r < 0) {
return -c_errno(); r = -c_errno();
goto error;
}
} }
r = bind(s, (struct sockaddr *)&address, sizeof(address)); r = bind(s, (struct sockaddr *)&address, sizeof(address));