From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: Ilya Maximets Date: Wed, 03 Aug 2016 08:22:49 +0300 Message-id: <1470201769-12344-1-git-send-email-i.maximets@samsung.com> Subject: [Qemu-devel] [PATCH] vhost: check for vhost_ops before using. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, "Michael S . Tsirkin" Cc: Dyasly Sergey , Marc-Andre Lureau , Heetae Ahn , Ilya Maximets '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 --- 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); } -- 2.7.4