]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Linux: close the netlink privsep socket once done.
authorRoy Marples <roy@marples.name>
Tue, 14 Jan 2020 11:53:29 +0000 (11:53 +0000)
committerRoy Marples <roy@marples.name>
Tue, 14 Jan 2020 11:53:29 +0000 (11:53 +0000)
src/privsep-linux.c

index 375d4d4af2a5ce11a0da3d4d4163869c35f754d9..cb876d1e9d28e195a488d2263c6d93ee2bfc6c3d 100644 (file)
@@ -48,14 +48,20 @@ ps_root_dosendnetlink(int protocol, struct msghdr *msg)
                .iov_base = buf,
                .iov_len = sizeof(buf),
        };
+       ssize_t retval;
 
        if ((s = if_linksocket(&snl, protocol)) == -1)
                return -1;
 
-       if (sendmsg(s, msg, 0) == -1)
-               return -1;
+       if (sendmsg(s, msg, 0) == -1) {
+               retval = -1;
+               goto out;
+       }
 
-       return if_getnetlink(NULL, &riov, s, 0, NULL, NULL);
+       retval = if_getnetlink(NULL, &riov, s, 0, NULL, NULL);
+out:
+       close(s);
+       return retval;
 }
 
 static ssize_t