[PATCH net 3/4] selftests: mptcp: close fd_in before returning in main_loop

From: Matthieu Baerts (NGI0)
Date: Fri Mar 28 2025 - 10:32:29 EST


From: Geliang Tang <tanggeliang@xxxxxxxxxx>

The file descriptor 'fd_in' is opened when cfg_input is configured, but
not closed in main_loop(), this patch fixes it.

Fixes: 05be5e273c84 ("selftests: mptcp: add disconnect tests")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Cong Liu <liucong2@xxxxxxxxxx>
Signed-off-by: Cong Liu <liucong2@xxxxxxxxxx>
Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
---
tools/testing/selftests/net/mptcp/mptcp_connect.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 893dc36b12f607bec56a41c9961eff272a7837c7..c83a8b47bbdfa5fcf1462e2b2949b41fd32c9b14 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -1299,7 +1299,7 @@ int main_loop(void)

ret = copyfd_io(fd_in, fd, 1, 0, &winfo);
if (ret)
- return ret;
+ goto out;

if (cfg_truncate > 0) {
shutdown(fd, SHUT_WR);
@@ -1320,7 +1320,10 @@ int main_loop(void)
close(fd);
}

- return 0;
+out:
+ if (cfg_input)
+ close(fd_in);
+ return ret;
}

int parse_proto(const char *proto)

--
2.48.1