diff mbox series

[mptcp-next,v2,2/2] selftests: mptcp: close fds when copyfd_io fails

Message ID 961b887097ccaff040737256cd6a5e66485b4eea.1742355162.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded, archived
Headers show
Series cleanups for main_loop | expand

Checks

Context Check Description
matttbe/build success Build and static analysis OK
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/KVM_Validation__normal warning Unstable: 1 failed test(s): selftest_mptcp_connect
matttbe/KVM_Validation__debug warning Unstable: 1 failed test(s): selftest_mptcp_connect
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ success Success! ✅
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang March 19, 2025, 3:39 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

When copyfd_io fails, it should not simply return an error, but should
close all open file descriptors before that. Here an "out" tag is added
to do this.

Fixes: 05be5e273c84 ("selftests: mptcp: add disconnect tests")
Co-developed-by: Cong Liu <liucong2@kylinos.cn>
Signed-off-by: Cong Liu <liucong2@kylinos.cn>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 5301062a5f3b..f190f95a3338 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -1293,7 +1293,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);
@@ -1309,12 +1309,13 @@  int main_loop(void)
 		memset(&winfo, 0, sizeof(winfo));
 		goto again;
 	} else {
+out:
 		close(fd);
 	}
 
 	if (cfg_input)
 		close(fd_in);
-	return 0;
+	return ret;
 }
 
 int parse_proto(const char *proto)