vhost: check for vhost_ops before using.
PATCH 1/1 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.
--- hw/net/vhost_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/vhost_net.c +1 -1
@@ -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); }
Signature · 1 line
2.7.4
Hi
Quoted 18 lines · 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 <[email protected]>--- hw/net/vhost_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/vhost_net.c +0
-0
hw/net/vhost_net.c int vhost_set_vring_enable(NetClientState *nc, int · line 434
Quoted 8 lines
hw/net/vhost_net.c +1
-1@@ -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); }
would be nice for 2.7,
Quoted 6 lines
--
2.7.4--
Marc-André Lureau
Hi
Quoted 26 lines · Marc-André Lureau
Hi
Quoted 21 lines · 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 <[email protected]>--- hw/net/vhost_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/vhost_net.c +0
-0@@ -428,7 +428,7 @@ int vhost_set_vring_enable(NetClientState *nc, int enable) nc->vring_enable = enable;
Quoted 8 lines
hw/net/vhost_net.c int vhost_set_vring_enable(NetClientState *nc, int enable) · line 433
Quoted 5 lines
hw/net/vhost_net.c +1
-1-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); }would be nice for 2.7,
Michael, could you pick the fix for 2.7? thanks
Quoted 11 lines
Reviewed-by Marc-André Lureau <[email protected]>Quoted 6 lines
--
2.7.4--
Marc-André Lureau
Signature · 1 line
Marc-André Lureau