From dbf19b104503e4dea1616e03fa472f60d2cdfd4e Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 14 Jan 2020 11:53:29 +0000 Subject: [PATCH] Linux: close the netlink privsep socket once done. --- src/privsep-linux.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 -- 2.47.3