From: "Alex Bennée" <alex.bennee@linaro.org>
To: Cong Liu <liucong2@kylinos.cn>
Cc: Alexandre Iooss <erdnaxe@crans.org>,
Mahmoud Mandour <ma.mandourr@gmail.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v2] contrib/plugins: Close file descriptor on error return
Date: Mon, 23 Oct 2023 14:45:19 +0100 [thread overview]
Message-ID: <87msw94flu.fsf@linaro.org> (raw)
In-Reply-To: <20231018025225.1640122-1-liucong2@kylinos.cn>
Cong Liu <liucong2@kylinos.cn> writes:
> This patch closes the file descriptor fd on error return to avoid
> resource leak.
>
> Fixes: ec7ee95db909 ("contrib/plugins: fix coverity warning in lockstep")
> Signed-off-by: Cong Liu <liucong2@kylinos.cn>
> ---
> contrib/plugins/lockstep.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c
> index f0cb8792c6fa..237543b43a76 100644
> --- a/contrib/plugins/lockstep.c
> +++ b/contrib/plugins/lockstep.c
> @@ -257,6 +257,7 @@ static bool setup_socket(const char *path)
> sockaddr.sun_family = AF_UNIX;
> if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) {
> perror("bad path");
> + close(fd);
> return false;
> }
>
> @@ -303,6 +304,7 @@ static bool connect_socket(const char *path)
> sockaddr.sun_family = AF_UNIX;
> if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) {
> perror("bad path");
> + close(fd);
> return false;
> }
Sorry queued this version to plugins/next, thanks.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2023-10-23 13:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 9:31 [PATCH] contrib/plugins: Close file descriptor on connect failure Cong Liu
2023-10-18 2:52 ` [PATCH v2] contrib/plugins: Close file descriptor on error return Cong Liu
2023-10-23 13:45 ` Alex Bennée [this message]
2023-10-23 13:44 ` [PATCH] contrib/plugins: Close file descriptor on connect failure Alex Bennée
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=87msw94flu.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=liucong2@kylinos.cn \
--cc=ma.mandourr@gmail.com \
--cc=qemu-devel@nongnu.org \
/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.