Skip to content

Commit 35fbbcc

Browse files
shemmingerdavem330
authored andcommitted
netvsc: save pointer to parent netvsc_device in channel table
Keep back pointer in the per-channel data structure to avoid any possible RCU related issues when napi poll is called but netvsc_device is in RCU limbo. Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2a926f7 commit 35fbbcc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ struct net_device_context {
727727
/* Per channel data */
728728
struct netvsc_channel {
729729
struct vmbus_channel *channel;
730+
struct netvsc_device *net_device;
730731
const struct vmpacket_descriptor *desc;
731732
struct napi_struct napi;
732733
struct multi_send_data msd;

drivers/net/hyperv/netvsc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,11 @@ int netvsc_poll(struct napi_struct *napi, int budget)
12241224
{
12251225
struct netvsc_channel *nvchan
12261226
= container_of(napi, struct netvsc_channel, napi);
1227+
struct netvsc_device *net_device = nvchan->net_device;
12271228
struct vmbus_channel *channel = nvchan->channel;
12281229
struct hv_device *device = netvsc_channel_to_device(channel);
12291230
u16 q_idx = channel->offermsg.offer.sub_channel_index;
12301231
struct net_device *ndev = hv_get_drvdata(device);
1231-
struct netvsc_device *net_device = net_device_to_netvsc_device(ndev);
12321232
int work_done = 0;
12331233

12341234
/* If starting a new interval */
@@ -1307,6 +1307,7 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
13071307
struct netvsc_channel *nvchan = &net_device->chan_table[i];
13081308

13091309
nvchan->channel = device->channel;
1310+
nvchan->net_device = net_device;
13101311
}
13111312

13121313
/* Enable NAPI handler before init callbacks */

0 commit comments

Comments
 (0)