From patchwork Wed Jan 11 09:15:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6buE5reu?= X-Patchwork-Id: 9510159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5985C601E7 for ; Wed, 11 Jan 2017 14:31:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E10528648 for ; Wed, 11 Jan 2017 14:31:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42CF428659; Wed, 11 Jan 2017 14:31:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id BD1E128648 for ; Wed, 11 Jan 2017 14:31:46 +0000 (UTC) Received: from localhost ([::1]:54623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRJwH-0007QW-Lg for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Jan 2017 09:31:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRFUD-0000K6-Du for qemu-devel@nongnu.org; Wed, 11 Jan 2017 04:46:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRFU9-0007bA-HB for qemu-devel@nongnu.org; Wed, 11 Jan 2017 04:46:29 -0500 Received: from m15-9.126.com ([220.181.15.9]:7504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRFU8-0007YO-Rq for qemu-devel@nongnu.org; Wed, 11 Jan 2017 04:46:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=7e1um aaz3n1UtGirEcQEU0YOXPUqHPSKsC9NCiUSrQo=; b=adLg6ghKPIpIuC23WHTJa WEQDCb0+dRG0H4mTsBoXLSGXFPF5ToCs1/mk74q9s8ugVrNUcw2+6FFU3rp1oAEn mTWgPiWsPPxFV3j8hR4OFN0o8+IsIMPb13NKycQMQvpSH6tLphCAcmjQEc+rAlMs aYWfqh5fdPy1D1FIK022WY= Received: from h158309$126.com ( [103.29.140.58] ) by ajax-webmail-wmsvr9 (Coremail) ; Wed, 11 Jan 2017 17:15:31 +0800 (CST) X-Originating-IP: [103.29.140.58] Date: Wed, 11 Jan 2017 17:15:31 +0800 (CST) From: =?GBK?B?u8a7tA==?= To: qemu-devel@nongnu.org X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20160729(86883.8884) Copyright (c) 2002-2017 www.mailtech.cn 126com X-CM-CTRLDATA: IAQ+YmZvb3Rlcl9odG09MjAzNDo1Ng== MIME-Version: 1.0 Message-ID: <32da9f1f.9022.1598ccf96ce.Coremail.h158309@126.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: CcqowADXRMi093VYz07CAA--.33894W X-CM-SenderInfo: rkrvmjiqz6ij2wof0z/1tbiYAtcNVbdXKyixwACse X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.15.9 X-Mailman-Approved-At: Wed, 11 Jan 2017 09:31:11 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] vhost-user: fix crash when chardev-remove X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Huai Huang @@ -192,7 +195,8 @@ static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond, { VhostUserState *s = opaque; - qemu_chr_disconnect(s->chr); + if (s->chr) + qemu_chr_disconnect(s->chr); return FALSE; } diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index f2d49ad..4037cf4 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -412,7 +412,6 @@ VHostNetState *get_vhost_net(NetClientState *nc) break; case NET_CLIENT_DRIVER_VHOST_USER: vhost_net = vhost_user_get_vhost_net(nc); - assert(vhost_net); break; default: break; diff --git a/net/vhost-user.c b/net/vhost-user.c index b0595f8..4e54478 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -160,7 +160,10 @@ static void vhost_user_cleanup(NetClientState *nc) qemu_chr_fe_release(s->chr); s->chr = NULL; } - + if (s->watch) { + g_source_remove(s->watch); + s->watch = 0; + } qemu_purge_queued_packets(nc); }