aboutsummaryrefslogtreecommitdiff
path: root/libcacard
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2013-06-04 16:23:37 -0400
committerMichael Tokarev <mjt@tls.msk.ru>2013-06-12 16:04:43 +0400
commit581fe784c3adf85dc167a47a4a60fd1245a98217 (patch)
tree07cdd480b6729553903bd1a1acf70cae14ff7e28 /libcacard
parente098b45386a86fecc1e573d305a240a2f4aa461d (diff)
downloadqemu-arm-581fe784c3adf85dc167a47a4a60fd1245a98217.tar.gz
libcacard/vscclient: fix leakage of socket on error paths
Spotted by Coverity. Signed-off-by: Alon Levy <alevy@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'libcacard')
-rw-r--r--libcacard/vscclient.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index ac23647236..5180d2945a 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:
+ closesocket(sock);
+ return -1;
}
int
@@ -759,5 +763,6 @@ main(
g_io_channel_unref(channel_socket);
g_byte_array_unref(socket_to_send);
+ closesocket(sock);
return 0;
}