From: Geliang Tang <tanggeliang@kylinos.cn>
The pipe descriptor (pipefds[0]) is already closed in main() after
the client() function completes, making the explicit close in
connect_one_server() redundant and potentially harmful.
This patch removes the unnecessary close operations in both the sockopt
and inq test cases to prevent double-closing of file descriptors, which
could lead to undefined behavior if the descriptor is reused.
Fixes: ce9979129a0b ("selftests: mptcp: add mptcp getsockopt test cases")
Fixes: b51880568f20 ("selftests: mptcp: add inq test case")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_inq.c | 2 --
tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 1 -
2 files changed, 3 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/selftests/net/mptcp/mptcp_inq.c
index 40f2a1b24763..5e2b5913121f 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_inq.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c
@@ -314,8 +314,6 @@ static void connect_one_server(int fd, int unixfd)
close(fd);
ret = write(unixfd, "closed", 6);
assert(ret == 6);
-
- close(unixfd);
}
static void get_tcp_inq(struct msghdr *msgh, unsigned int *inqv)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index b44b6c9b0550..8d590629a8e9 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -593,7 +593,6 @@ static void connect_one_server(int fd, int pipefd)
/* un-block server */
ret = read(pipefd, buf2, 4);
assert(ret == 4);
- close(pipefd);
assert(strncmp(buf2, "xmit", 4) == 0);
--
2.48.1