From patchwork Wed Aug 3 05:22:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 9260767 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 43A1F6048F for ; Wed, 3 Aug 2016 05:23:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ADD4284EF for ; Wed, 3 Aug 2016 05:23:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F0142854D; Wed, 3 Aug 2016 05:23:41 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 DB18B284EF for ; Wed, 3 Aug 2016 05:23:39 +0000 (UTC) Received: from localhost ([::1]:60300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUoeX-0006xL-PB for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Aug 2016 01:23:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUoeG-0006xC-OQ for qemu-devel@nongnu.org; Wed, 03 Aug 2016 01:23:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUoeC-00083l-FR for qemu-devel@nongnu.org; Wed, 03 Aug 2016 01:23:19 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:26263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUoeC-00083M-9i for qemu-devel@nongnu.org; Wed, 03 Aug 2016 01:23:16 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OBB006QXIYLOY00@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 03 Aug 2016 06:23:09 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-c0-57a17fbda5a2 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 2C.08.05254.DBF71A75; Wed, 3 Aug 2016 06:23:09 +0100 (BST) Received: from imaximets.rnd.samsung.ru ([106.109.129.180]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OBB00ASFIYH1H70@eusync1.samsung.com>; Wed, 03 Aug 2016 06:23:09 +0100 (BST) From: Ilya Maximets To: qemu-devel@nongnu.org, "Michael S . Tsirkin" Date: Wed, 03 Aug 2016 08:22:49 +0300 Message-id: <1470201769-12344-1-git-send-email-i.maximets@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLJMWRmVeSWpSXmKPExsVy+t/xy7p76xeGG/TMUbOY9vk2u8WV9p/s Fgva2lkt/v96xWpxvHcHi8Xk2VIObB5Prm1m8ni/7yqbR9+WVYwBzFFcNimpOZllqUX6dglc GS//zGEtaGavWNXWydzA+Ii1i5GTQ0LARKJh/UUoW0ziwr31bCC2kMBSRon9fyq6GLmA7FYm iS3LF7GAJNgEdCROrT7CCGKLCDhKtDTMYAcpYhZYwyjR+eMDE0hCWMBS4m/7PDCbRUBVYtvf g8wgNq+Am8SjJ93sENvkJG6e62SewMi9gJFhFaNoamlyQXFSeq6hXnFibnFpXrpecn7uJkZI IHzZwbj4mNUhRgEORiUeXovzC8KFWBPLiitzDzFKcDArifDG1S0MF+JNSaysSi3Kjy8qzUkt PsQozcGiJM47d9f7ECGB9MSS1OzU1ILUIpgsEwenVAOj37m3rXYxb2ctnb49Vs+pzybE/FCE ntufXX83bzepl2VgYpo9wWPG5l/yOanb43ujk6ZfPh7qu/6Ud+QxvavGNh+/GHrMWNNfdTuK 8bKRdtLl+IqLyRtZH1nt2n/qbMrcFb21n7n5A/g6J8iUTfoXdEXa/OedpVIWF67FvnJnvXBh ff3HsoZeJZbijERDLeai4kQAeLQ53AACAAA= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.14 Subject: [Qemu-devel] [PATCH] vhost: check for vhost_ops before using. 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: , Cc: Ilya Maximets , Marc-Andre Lureau , Heetae Ahn , Dyasly Sergey Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 'vhost_set_vring_enable()' tries to call function using pointer to 'vhost_ops' which can be already zeroized in 'vhost_dev_cleanup()' while vhost disconnection. Fix that by checking 'vhost_ops' before using. This fixes QEMU crash on calling 'ethtool -L eth0 combined 2' if vhost disconnected. Signed-off-by: Ilya Maximets Reviewed-by: Marc-André Lureau --- hw/net/vhost_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index dc61dc1..f2d49ad 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -428,7 +428,7 @@ int vhost_set_vring_enable(NetClientState *nc, int enable) nc->vring_enable = enable; - if (vhost_ops->vhost_set_vring_enable) { + if (vhost_ops && vhost_ops->vhost_set_vring_enable) { return vhost_ops->vhost_set_vring_enable(&net->dev, enable); }