From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] libcacard/vscclient: fix leakage of socket on error paths
Date: Fri, 31 May 2013 13:58:59 -0400 (EDT) [thread overview]
Message-ID: <1363588977.12263992.1370023139076.JavaMail.root@redhat.com> (raw)
In-Reply-To: <1370023006-4639-1-git-send-email-alevy@redhat.com>
> Spotted by Coverity.
>
Self NACK.
I'll send a more complete patch, and use closesocket.
> Signed-off-by: Alon Levy <alevy@redhat.com>
> ---
> libcacard/vscclient.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
> index ac23647..9fcc548 100644
> --- a/libcacard/vscclient.c
> +++ b/libcacard/vscclient.c
> @@ -618,18 +618,22 @@ connect_to_qemu(
> if (ret != 0) {
> /* Error */
> fprintf(stderr, "getaddrinfo failed\n");
> - return -1;
> + goto cleanup_socket;
> }
>
> if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
> /* Error */
> fprintf(stderr, "Could not connect\n");
> - return -1;
> + goto cleanup_socket;
> }
> if (verbose) {
> printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
> }
> return sock;
> +
> +cleanup_socket:
> + close(sock);
> + return -1;
> }
>
> int
> --
> 1.8.2.1
>
>
>
prev parent reply other threads:[~2013-05-31 17:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-31 17:56 [Qemu-devel] [PATCH] libcacard/vscclient: fix leakage of socket on error paths Alon Levy
2013-05-31 17:58 ` Alon Levy [this message]
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=1363588977.12263992.1370023139076.JavaMail.root@redhat.com \
--to=alevy@redhat.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.