All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: wangyunjian <wangyunjian@huawei.com>,
	davem@davemloft.net, mst@redhat.com, rusty@rustcorp.com.au,
	netdev@vger.kernel.org
Cc: liuyongan@huawei.com
Subject: Re: [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv
Date: Thu, 26 May 2016 17:33:17 +0800	[thread overview]
Message-ID: <5746C2DD.8090604@redhat.com> (raw)
In-Reply-To: <5746976F.60306@huawei.com>



On 2016年05月26日 14:27, wangyunjian wrote:
> In function virtnet_open() and virtnet_probe(), func try_fill_recv()
> will be executed at the same time. VQ in virtqueue_add() is not protected
> well and BUG_ON will be triggered when virito_net.ko being removed.
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   drivers/net/virtio_net.c | 18 ++----------------
>   1 file changed, 2 insertions(+), 16 deletions(-)

The patch is needed for stable.

Acked-by: Jason Wang <jasowang@redhat.com>

>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 49d84e5..e0638e5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1925,24 +1925,11 @@ static int virtnet_probe(struct virtio_device *vdev)
>
>          virtio_device_ready(vdev);
>
> -       /* Last of all, set up some receive buffers. */
> -       for (i = 0; i < vi->curr_queue_pairs; i++) {
> -               try_fill_recv(vi, &vi->rq[i], GFP_KERNEL);
> -
> -               /* If we didn't even get one input buffer, we're useless. */
> -               if (vi->rq[i].vq->num_free ==
> -                   virtqueue_get_vring_size(vi->rq[i].vq)) {
> -                       free_unused_bufs(vi);
> -                       err = -ENOMEM;
> -                       goto free_recv_bufs;
> -               }
> -       }
> -
>          vi->nb.notifier_call = &virtnet_cpu_callback;
>          err = register_hotcpu_notifier(&vi->nb);
>          if (err) {
>                  pr_debug("virtio_net: registering cpu notifier failed\n");
> -               goto free_recv_bufs;
> +               goto free_unregister_netdev;
>          }
>
>          /* Assume link up if device can't report link status,
> @@ -1960,10 +1947,9 @@ static int virtnet_probe(struct virtio_device *vdev)
>
>          return 0;
>
> -free_recv_bufs:
> +free_unregister_netdev:
>          vi->vdev->config->reset(vdev);
>
> -       free_receive_bufs(vi);
>          unregister_netdev(dev);
>   free_vqs:
>          cancel_delayed_work_sync(&vi->refill);
> --
> 1.7.12.4
>
>

  reply	other threads:[~2016-05-26  9:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26  6:27 [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv wangyunjian
2016-05-26  9:33 ` Jason Wang [this message]
2016-05-26  9:36 ` Michael S. Tsirkin
2016-05-30  5:31 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5746C2DD.8090604@redhat.com \
    --to=jasowang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=liuyongan@huawei.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=wangyunjian@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.