From: Ilya Maximets Date: Wed, 3 Aug 2016 05:22:49 +0000 (+0300) Subject: vhost: check for vhost_ops before using. X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ca10203cde7cf37623e0e77da1696ba1fbce5d84;p=qemu.git vhost: check for vhost_ops before using. '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 --- diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index dc61dc1c5f..f2d49ad7e7 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); }