From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9Kre-0005xO-Uz for qemu-devel@nongnu.org; Wed, 05 Sep 2012 15:02:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9Krd-0003R1-O6 for qemu-devel@nongnu.org; Wed, 05 Sep 2012 15:02:14 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:59180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9Krd-0003Qv-HE for qemu-devel@nongnu.org; Wed, 05 Sep 2012 15:02:13 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Sep 2012 13:02:12 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id E379719D8046 for ; Wed, 5 Sep 2012 13:02:08 -0600 (MDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q85J25AQ202190 for ; Wed, 5 Sep 2012 13:02:05 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q85J1hPg010889 for ; Wed, 5 Sep 2012 13:01:44 -0600 From: Anthony Liguori Date: Wed, 5 Sep 2012 14:01:36 -0500 Message-Id: <1346871696-8150-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH] socket: don't attempt to reconnect a TCP socket in server mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Lei Li Commit c3767ed0eb5d0bb25fe409ae5dec06e3411ff1b6 introduced a possible SEGV when using a socket chardev with server=on because it assumes that all TCP sockets are in client mode. This patch adds a check to only reconnect when in client mode. Cc: Lei Li Reported-by: Michael Roth Signed-off-by: Anthony Liguori --- qemu-char.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 398baf1..767da93 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2148,10 +2148,12 @@ static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len) TCPCharDriver *s = chr->opaque; if (s->connected) { return send_all(s->fd, buf, len); - } else { + } else if (s->listen_fd == -1) { /* (Re-)connect for unconnected writing */ tcp_chr_connect(chr); return 0; + } else { + return len; } } -- 1.7.5.4