virtio-net: only delete bh that existed
PATCH 1/1 virtio-net: only delete bh that existed
We delete without check whether it existed during exit. This will lead NULL pointer deference since it was created conditionally depends on guest driver status and features. So add a check of existence before trying to delete it.
--- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/virtio-net.c +1 -1
@@ -1601,7 +1601,7 @@ static int virtio_net_device_exit(DeviceState *qdev)if (q->tx_timer) {timer_del (q->tx_timer);timer_free (q->tx_timer); - }else { + }else if (q->tx_bh) {qemu_bh_delete (q->tx_bh); } }
Signature · 1 line
1.8.3.2
Il 06/11/2013 09:58, Jason Wang ha scritto:
Quoted 16 lines
We delete without check whether it existed during exit. This will lead NULL pointer deference since it was created conditionally depends on guest driver status and features. So add a check of existence before trying to delete it.
Signed-off-by Jason Wang <[email protected]>--- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/virtio-net.c +0
-0
hw/net/virtio-net.c static int virtio_net_device_exit(DeviceState *qdev) · line 1607
Quoted 8 lines
hw/net/virtio-net.c +1
-1@@ -1601,7 +1601,7 @@ static int virtio_net_device_exit(DeviceState *qdev)if (q->tx_timer) {timer_del (q->tx_timer);timer_free (q->tx_timer); - }else { + }else if (q->tx_bh) {qemu_bh_delete (q->tx_bh); } }
Please remember to add 1.7 in the subject at this time.
Paolo
Quoted 6 lines · Jason Wang
We delete without check whether it existed during exit. This will lead NULL pointer deference since it was created conditionally depends on guest driver status and features. So add a check of existence before trying to delete it.
Signed-off-by Jason Wang <[email protected]>
Looks like the bug was introduced by:
commit 17ec5a8686143da66208273d355f2eeb09807614 Author: KONRAD Frederic <[email protected]> Date: Thu Apr 11 16:29:57 2013 +0200 virtio-net: add the virtio-net device.
Before that we had a single bh and created/destroyed that unconditionally.
Is this a correct analysis?
Quoted 19 lines
--- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/virtio-net.c +1
-1@@ -1601,7 +1601,7 @@ static int virtio_net_device_exit(DeviceState *qdev)if (q->tx_timer) {timer_del (q->tx_timer);timer_free (q->tx_timer); - }else { + }else if (q->tx_bh) {qemu_bh_delete (q->tx_bh); } }Signature · 1 line
1.8.3.2
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Jason Wang
We delete without check whether it existed during exit. This will lead NULL pointer deference since it was created conditionally depends on guest driver status and features. So add a check of existence before trying to delete it.
Signed-off-by Jason Wang <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>Looks like the bug was introduced by:
Quoted 9 lines
commit 17ec5a8686143da66208273d355f2eeb09807614 Author: KONRAD Frederic <[email protected]> Date: Thu Apr 11 16:29:57 2013 +0200 virtio-net: add the virtio-net device.Before that we had a single bh and created/destroyed that unconditionally.
Is this a correct analysis?
Nope, it was introduced in the multiqueue virito-net, since the bh were created conditionally from that commit.
commit fed699f9ca6ae8a0fb62803334cf46fa64d1eb91
Author: Jason Wang <[email protected]> Date: Wed Jan 30 19:12:39 2013 +0800
virtio-net: multiqueue support
Quoted 20 lines
Quoted 20 lines
--- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/virtio-net.c +1
-1@@ -1601,7 +1601,7 @@ static int virtio_net_device_exit(DeviceState *qdev)if (q->tx_timer) {timer_del (q->tx_timer);timer_free (q->tx_timer); - }else { + }else if (q->tx_bh) {qemu_bh_delete (q->tx_bh); } }Signature · 1 line
1.8.3.2