summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-02 11:26:25 +0200
committerThomas Haller <thaller@redhat.com>2019-08-02 11:26:25 +0200
commitc8cee413dddd4a6bb45beb601b93c201ee1b5be1 (patch)
tree03a554beb7693d84806a0c3f1b3e15468beaf04d
parentd3bd7b9bee12fd0c4e2ebc80b102fa86b8a9777c (diff)
downloadNetworkManager-c8cee413dddd4a6bb45beb601b93c201ee1b5be1.tar.gz
n-acd: fix leaking socket handle in n_acd_socket_new() when setsockopt() fails
Found by Coverity.
-rw-r--r--shared/n-acd/src/n-acd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/shared/n-acd/src/n-acd.c b/shared/n-acd/src/n-acd.c
index a0a48c5889..d434d1d14e 100644
--- a/shared/n-acd/src/n-acd.c
+++ b/shared/n-acd/src/n-acd.c
@@ -127,8 +127,10 @@ static int n_acd_socket_new(int *fdp, int fd_bpf_prog, NAcdConfig *config) {
if (fd_bpf_prog >= 0) {
r = setsockopt(s, SOL_SOCKET, SO_ATTACH_BPF, &fd_bpf_prog, sizeof(fd_bpf_prog));
- if (r < 0)
- return -c_errno();
+ if (r < 0) {
+ r = -c_errno();
+ goto error;
+ }
}
r = bind(s, (struct sockaddr *)&address, sizeof(address));