From patchwork Tue Feb 23 18:10:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 8395231 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0D5C1C0553 for ; Tue, 23 Feb 2016 18:13:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B650202EB for ; Tue, 23 Feb 2016 18:13:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4758202E6 for ; Tue, 23 Feb 2016 18:13:50 +0000 (UTC) Received: from localhost ([::1]:59063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYHT4-0001X9-99 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 23 Feb 2016 13:13:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYHQS-0005ay-Bj for qemu-devel@nongnu.org; Tue, 23 Feb 2016 13:11:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYHQP-0003FH-Sm for qemu-devel@nongnu.org; Tue, 23 Feb 2016 13:11:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYHQP-0003FC-N7 for qemu-devel@nongnu.org; Tue, 23 Feb 2016 13:11:05 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 62399627FE for ; Tue, 23 Feb 2016 18:11:05 +0000 (UTC) Received: from localhost (ovpn-113-127.phx2.redhat.com [10.3.113.127]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1NIB4WC002205; Tue, 23 Feb 2016 13:11:04 -0500 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Tue, 23 Feb 2016 19:10:53 +0100 Message-Id: <1456251053-25960-6-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1456251053-25960-1-git-send-email-marcandre.lureau@redhat.com> References: <1456251053-25960-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 23 Feb 2016 18:11:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , jasowang@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 5/5] qemu-char: make tcp_chr_disconnect() reentrant-safe 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau During CHR_EVENT_CLOSED, the function could be reentered, make this case safe. Signed-off-by: Marc-André Lureau --- qemu-char.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu-char.c b/qemu-char.c index dc433a6..9bd568b 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2769,6 +2769,10 @@ static void tcp_chr_disconnect(CharDriverState *chr) { TCPCharDriver *s = chr->opaque; + if (!s->connected) { + return; + } + s->connected = 0; if (s->listen_ioc) { s->listen_tag = qio_channel_add_watch(