From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiTbR-0006Aq-A8 for qemu-devel@nongnu.org; Fri, 31 May 2013 13:59:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiTbQ-0002XB-8l for qemu-devel@nongnu.org; Fri, 31 May 2013 13:59:01 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:34493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiTbP-0002Wz-Vz for qemu-devel@nongnu.org; Fri, 31 May 2013 13:59:00 -0400 Received: from zmail15.collab.prod.int.phx2.redhat.com (zmail15.collab.prod.int.phx2.redhat.com [10.5.83.17]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r4VHwxnb025083 for ; Fri, 31 May 2013 13:58:59 -0400 Date: Fri, 31 May 2013 13:58:59 -0400 (EDT) From: Alon Levy Message-ID: <1363588977.12263992.1370023139076.JavaMail.root@redhat.com> In-Reply-To: <1370023006-4639-1-git-send-email-alevy@redhat.com> References: <1370023006-4639-1-git-send-email-alevy@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] libcacard/vscclient: fix leakage of socket on error paths List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org > Spotted by Coverity. > Self NACK. I'll send a more complete patch, and use closesocket. > Signed-off-by: Alon Levy > --- > 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 > > >