Skip to content

Commit 2be0f26

Browse files
shemmingerdavem330
authored andcommitted
netvsc: make sure napi enabled before vmbus_open
This fixes a race where vmbus callback for new packet arriving could occur before NAPI is initialized. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5900eca commit 2be0f26

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,23 +1322,25 @@ int netvsc_device_add(struct hv_device *device,
13221322
nvchan->channel = device->channel;
13231323
}
13241324

1325+
/* Enable NAPI handler before init callbacks */
1326+
netif_napi_add(ndev, &net_device->chan_table[0].napi,
1327+
netvsc_poll, NAPI_POLL_WEIGHT);
1328+
13251329
/* Open the channel */
13261330
ret = vmbus_open(device->channel, ring_size * PAGE_SIZE,
13271331
ring_size * PAGE_SIZE, NULL, 0,
13281332
netvsc_channel_cb,
13291333
net_device->chan_table);
13301334

13311335
if (ret != 0) {
1336+
netif_napi_del(&net_device->chan_table[0].napi);
13321337
netdev_err(ndev, "unable to open channel: %d\n", ret);
13331338
goto cleanup;
13341339
}
13351340

13361341
/* Channel is opened */
13371342
netdev_dbg(ndev, "hv_netvsc channel opened successfully\n");
13381343

1339-
/* Enable NAPI handler for init callbacks */
1340-
netif_napi_add(ndev, &net_device->chan_table[0].napi,
1341-
netvsc_poll, NAPI_POLL_WEIGHT);
13421344
napi_enable(&net_device->chan_table[0].napi);
13431345

13441346
/* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is

drivers/net/hyperv/rndis_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
10181018
if (ret == 0)
10191019
napi_enable(&nvchan->napi);
10201020
else
1021-
netdev_err(ndev, "sub channel open failed (%d)\n", ret);
1021+
netif_napi_del(&nvchan->napi);
10221022

10231023
if (refcount_dec_and_test(&nvscdev->sc_offered))
10241024
complete(&nvscdev->channel_init_wait);

0 commit comments

Comments
 (0)