Skip to content

Commit 8348e04

Browse files
shemmingerdavem330
authored andcommitted
hv_netvsc: disable NAPI before channel close
This makes sure that no CPU is still process packets when the channel is closed. Fixes: 76bb5db ("netvsc: fix use after free on module removal") Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 68e2ffd commit 8348e04

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ void netvsc_device_remove(struct hv_device *device)
568568

569569
RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
570570

571+
/* And disassociate NAPI context from device */
572+
for (i = 0; i < net_device->num_chn; i++)
573+
netif_napi_del(&net_device->chan_table[i].napi);
574+
571575
/*
572576
* At this point, no one should be accessing net_device
573577
* except in here
@@ -579,10 +583,6 @@ void netvsc_device_remove(struct hv_device *device)
579583

580584
netvsc_teardown_gpadl(device, net_device);
581585

582-
/* And dissassociate NAPI context from device */
583-
for (i = 0; i < net_device->num_chn; i++)
584-
netif_napi_del(&net_device->chan_table[i].napi);
585-
586586
/* Release all resources */
587587
free_netvsc_device_rcu(net_device);
588588
}

0 commit comments

Comments
 (0)