Received: from eggs.gnu.org ([2001:4830:134:3::10]:51613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzKH-0001qy-FT for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:02:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpzKD-00061j-GS for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:02:13 -0400 From: "Daniel P. Berrange" Date: Fri, 30 Sep 2016 16:02:01 +0100 Message-Id: <1475247721-30670-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH] char: fix missing return in error path for chardev TLS init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, qemu-trivial@nongnu.org, Paolo Bonzini , "Daniel P. Berrange" If the qio_channel_tls_new_(server|client) methods fail, we disconnect the client. Unfortunately a missing return means we then go on to try and run the TLS handshake on a NULL I/O channel. This gives predictably segfaulty results. The main way to trigger this is to request a bogus TLS priority string for the TLS credentials. e.g. -object tls-creds-x509,id=tls0,priority=wibble,... Most other ways appear impossible to trigger except perhaps if OOM conditions cause gnutls initialization to fail. Signed-off-by: Daniel P. Berrange --- qemu-char.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qemu-char.c b/qemu-char.c index fb456ce..48a45ef 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3132,6 +3132,7 @@ static void tcp_chr_tls_init(CharDriverState *chr) if (tioc == NULL) { error_free(err); tcp_chr_disconnect(chr); + return; } object_unref(OBJECT(s->ioc)); s->ioc = QIO_CHANNEL(tioc); -- 2.7.4