Skip to content

Commit

Permalink
Netvsc: Call hv_unmap_memory() in the netvsc_device_remove()
Browse files Browse the repository at this point in the history
netvsc_device_remove() calls vunmap() inside which should not be
called in the interrupt context. Current code calls hv_unmap_memory()
in the free_netvsc_device() which is rcu callback and maybe called
in the interrupt context. This will trigger BUG_ON(in_interrupt())
in the vunmap(). Fix it via moving hv_unmap_memory() to netvsc_device_
remove().

Fixes: 846da38 ("net: netvsc: Add Isolation VM support for netvsc driver")
Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tianyu Lan authored and David S. Miller committed Feb 9, 2022
1 parent 4d8cb5f commit b539324
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,15 @@ static void free_netvsc_device(struct rcu_head *head)

kfree(nvdev->extension);

if (nvdev->recv_original_buf) {
hv_unmap_memory(nvdev->recv_buf);
if (nvdev->recv_original_buf)
vfree(nvdev->recv_original_buf);
} else {
else
vfree(nvdev->recv_buf);
}

if (nvdev->send_original_buf) {
hv_unmap_memory(nvdev->send_buf);
if (nvdev->send_original_buf)
vfree(nvdev->send_original_buf);
} else {
else
vfree(nvdev->send_buf);
}

bitmap_free(nvdev->send_section_map);

Expand Down Expand Up @@ -765,6 +761,12 @@ void netvsc_device_remove(struct hv_device *device)
netvsc_teardown_send_gpadl(device, net_device, ndev);
}

if (net_device->recv_original_buf)
hv_unmap_memory(net_device->recv_buf);

if (net_device->send_original_buf)
hv_unmap_memory(net_device->send_buf);

/* Release all resources */
free_netvsc_device_rcu(net_device);
}
Expand Down Expand Up @@ -1821,6 +1823,12 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
netif_napi_del(&net_device->chan_table[0].napi);

cleanup2:
if (net_device->recv_original_buf)
hv_unmap_memory(net_device->recv_buf);

if (net_device->send_original_buf)
hv_unmap_memory(net_device->send_buf);

free_netvsc_device(&net_device->rcu);

return ERR_PTR(ret);
Expand Down

0 comments on commit b539324

Please sign in to comment.