[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] virtio-net: only delete bh that existed
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH] virtio-net: only delete bh that existed |
Date: |
Wed, 6 Nov 2013 13:17:04 +0200 |
On Wed, Nov 06, 2013 at 04:58:08PM +0800, Jason Wang wrote:
> 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.
>
> Cc: address@hidden
> Signed-off-by: Jason Wang <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Looks like the bug was introduced by:
commit 17ec5a8686143da66208273d355f2eeb09807614
Author: KONRAD Frederic <address@hidden>
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?
> ---
> hw/net/virtio-net.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 22dbd05..ae51d96 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -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);
> }
> }
> --
> 1.8.3.2