aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstephen hemminger <stephen@networkplumber.org>2017-03-16 12:21:32 -0700
committerDavid S. Miller <davem@davemloft.net>2017-03-16 21:35:33 -0700
commite14b4db7a567ff507453ecd9c64da51bbc2b6d23 (patch)
tree848ad14f3144221ffdfc0e91901e11dae7dfdfc8
parentbridge: resolve a false alarm of lockdep (diff)
downloadlinux-dev-e14b4db7a567ff507453ecd9c64da51bbc2b6d23.tar.xz
linux-dev-e14b4db7a567ff507453ecd9c64da51bbc2b6d23.zip
netvsc: fix race during initialization
When device is being setup on boot, there is a small race where network device callback is registered, but the netvsc_device pointer is not set yet. This can cause a NULL ptr dereference if packet arrives during this window. Fixes: 46b4f7f5d1f7 ("netvsc: eliminate per-device outstanding send counter") Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/hyperv/netvsc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 4c1d8cca247b..8dd0b8770328 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1231,8 +1231,11 @@ void netvsc_channel_cb(void *context)
return;
net_device = net_device_to_netvsc_device(ndev);
- if (unlikely(net_device->destroy) &&
- netvsc_channel_idle(net_device, q_idx))
+ if (unlikely(!net_device))
+ return;
+
+ if (unlikely(net_device->destroy &&
+ netvsc_channel_idle(net_device, q_idx)))
return;
/* commit_rd_index() -> hv_signal_on_read() needs this. */