If sendmsg() fails, tcpdiag_send() and sockdiag_send() close the netlink socket, then inet_show_netlink() closes it again via rtnl_close(). The second close clobbers errno with EBADF. Leave closing the socket to the caller. Signed-off-by: Stephen Hemminger --- misc/ss.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/misc/ss.c b/misc/ss.c index cffee883..674ed8e8 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -3931,10 +3931,8 @@ static int tcpdiag_send(int fd, int protocol, struct filter *f) .msg_iovlen = iovlen, }; - if (sendmsg(fd, &msg, 0) < 0) { - close(fd); + if (sendmsg(fd, &msg, 0) < 0) return -1; - } return 0; } @@ -4026,7 +4024,6 @@ static int sockdiag_send(int family, int fd, int protocol, struct filter *f) if (sendmsg(fd, &msg, 0) < 0) { free(bpf_rta); - close(fd); return -1; } -- 2.53.0