Received: from eggs.gnu.org ([2001:4830:134:3::10]:45471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXVSN-0001sq-5h for qemu-devel@nongnu.org; Wed, 10 Aug 2016 11:30:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXVSJ-0008G4-Rh for qemu-devel@nongnu.org; Wed, 10 Aug 2016 11:30:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXVSJ-0008Fh-Lt for qemu-devel@nongnu.org; Wed, 10 Aug 2016 11:30:07 -0400 Date: Wed, 10 Aug 2016 18:30:03 +0300 From: "Michael S. Tsirkin" Message-ID: <1470842980-32481-2-git-send-email-mst@redhat.com> References: <1470842980-32481-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1470842980-32481-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 1/3] vhost: check for vhost_ops before using. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Ilya Maximets , Jason Wang From: 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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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); } -- MST