From: Geliang Tang <geliang@kernel.org>
To: Cong Liu <liucong2@kylinos.cn>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH 3/3] selftests: mptcp: Clean up resources properly in main_loop
Date: Wed, 15 Jan 2025 09:13:23 +0800 [thread overview]
Message-ID: <40ddb2e67cbbd7178c5ad3766b8b51bfa7ab0e03.camel@kernel.org> (raw)
In-Reply-To: <20250113085228.121778-4-liucong2@kylinos.cn>
cc mptcp only.
On Mon, 2025-01-13 at 16:52 +0800, Cong Liu wrote:
> Add proper cleanup of resources (file descriptors and address info)
> in error paths to prevent resource leaks.
>
> Signed-off-by: Cong Liu <liucong2@kylinos.cn>
> ---
> tools/testing/selftests/net/mptcp/mptcp_connect.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index 4d4ea4627daa..e82fde0411b2 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -1271,8 +1271,13 @@ int main_loop(void)
> }
>
> ret = copyfd_io(fd_in, fd, 1, 0, &winfo);
> - if (ret)
> + if (ret) {
> + close(fd);
> + if (cfg_input)
> + close(fd_in);
Should 'listensock' be closed here?
> + freeaddrinfo(peer);
> return ret;
> + }
>
> if (cfg_truncate > 0) {
> xdisconnect(fd, peer->ai_addrlen);
> @@ -1291,6 +1296,7 @@ int main_loop(void)
> goto again;
> } else {
> close(fd);
Should 'fd_in' be closed here? If so, is it possible to use a 'goto
out;' to reduce duplication of code?
Thanks,
-Geliang
> + freeaddrinfo(peer);
> }
>
> return 0;
next prev parent reply other threads:[~2025-01-15 1:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 8:52 [PATCH 0/3] selftests: mptcp: Fix various issues in main_loop Cong Liu
2025-01-13 8:52 ` [PATCH 1/3] selftests: mptcp: Fix incorrect file descriptor check " Cong Liu
2025-01-13 8:52 ` [PATCH 2/3] selftests: mptcp: Fix input fd lifecycle in reconnection loop Cong Liu
2025-01-15 1:06 ` Geliang Tang
2025-01-13 8:52 ` [PATCH 3/3] selftests: mptcp: Clean up resources properly in main_loop Cong Liu
2025-01-15 1:13 ` Geliang Tang [this message]
2025-01-13 16:39 ` [PATCH 0/3] selftests: mptcp: Fix various issues " MPTCP CI
2025-01-13 16:50 ` MPTCP CI
2025-01-14 18:16 ` Matthieu Baerts
2025-01-16 8:54 ` [PATCH v2] selftests: mptcp: Fix incorrect file descriptor check " Cong Liu
2025-01-16 16:29 ` Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40ddb2e67cbbd7178c5ad3766b8b51bfa7ab0e03.camel@kernel.org \
--to=geliang@kernel.org \
--cc=liucong2@kylinos.cn \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.