From: Roy Marples Date: Tue, 14 Jan 2020 11:53:29 +0000 (+0000) Subject: Linux: close the netlink privsep socket once done. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbf19b104503e4dea1616e03fa472f60d2cdfd4e;p=thirdparty%2Fdhcpcd.git Linux: close the netlink privsep socket once done. --- diff --git a/src/privsep-linux.c b/src/privsep-linux.c index 375d4d4a..cb876d1e 100644 --- a/src/privsep-linux.c +++ b/src/privsep-linux.c @@ -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