From patchwork Wed Sep 5 19:01:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 181916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 30E662C0095 for ; Thu, 6 Sep 2012 05:02:27 +1000 (EST) Received: from localhost ([::1]:47556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9Krp-0005xx-BZ for incoming@patchwork.ozlabs.org; Wed, 05 Sep 2012 15:02:25 -0400 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 d03dlp03.boulder.ibm.com (9.17.202.179) by e39.co.us.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 5 Sep 2012 13:02:09 -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 Received: from titi.austin.rr.com (sig-9-65-197-11.mts.ibm.com [9.65.197.11]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q85J1eVm010440; Wed, 5 Sep 2012 13:01:41 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 5 Sep 2012 14:01:36 -0500 Message-Id: <1346871696-8150-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12090519-4242-0000-0000-000002CB5A1E X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.160 Cc: Anthony Liguori , Lei Li Subject: [Qemu-devel] [PATCH] socket: don't attempt to reconnect a TCP socket in server mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; } }