Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1462950
| From | Vitaly Kuznetsov <vkuznets@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH net v2 4/5] hv_netvsc: protect module refcount by checking net_device_ctx->vf_netdev |
| Date | 2016-08-15 17:50 +0200 |
| Message-ID | <s6sjg-7pG-35@gated-at.bofh.it> (permalink) |
| References | <s6sjf-7pG-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
We're not guaranteed to see NETDEV_REGISTER/NETDEV_UNREGISTER notifications only once per VF but we increase/decrease module refcount unconditionally. Check vf_netdev to make sure we don't take/release it twice. We presume that only one VF per netvsc device may exist. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Acked-by: Haiyang Zhang <haiyangz@microsoft.com> --- drivers/net/hyperv/netvsc_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 2c90883..62a4e6e 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1193,7 +1193,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev) net_device_ctx = netdev_priv(ndev); netvsc_dev = net_device_ctx->nvdev; - if (netvsc_dev == NULL) + if (!netvsc_dev || net_device_ctx->vf_netdev) return NOTIFY_DONE; netdev_info(ndev, "VF registering: %s\n", vf_netdev->name); @@ -1312,7 +1312,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev) net_device_ctx = netdev_priv(ndev); netvsc_dev = net_device_ctx->nvdev; - if (netvsc_dev == NULL) + if (!netvsc_dev || !net_device_ctx->vf_netdev) return NOTIFY_DONE; netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name); netvsc_inject_disable(net_device_ctx); -- 2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net v2 0/5] hv_netvsc: fixes for VF removal path Vitaly Kuznetsov <vkuznets@redhat.com> - 2016-08-15 17:50 +0200 [PATCH net v2 1/5] hv_netvsc: don't lose VF information Vitaly Kuznetsov <vkuznets@redhat.com> - 2016-08-15 17:50 +0200 [PATCH net v2 3/5] hv_netvsc: reset vf_inject on VF removal Vitaly Kuznetsov <vkuznets@redhat.com> - 2016-08-15 17:50 +0200 [PATCH net v2 4/5] hv_netvsc: protect module refcount by checking net_device_ctx->vf_netdev Vitaly Kuznetsov <vkuznets@redhat.com> - 2016-08-15 17:50 +0200 Re: [PATCH net v2 0/5] hv_netvsc: fixes for VF removal path David Miller <davem@davemloft.net> - 2016-08-15 22:50 +0200
csiph-web