Skip to content

Commit 758c57d

Browse files
committed
vxlan: fix crash from work pending on module removal
Switch to using a per module work queue so that all the socket deletion callbacks are done when module is removed. Signed-off-by: Stephen Hemminger <[email protected]>
1 parent b715398 commit 758c57d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/net/vxlan.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct vxlan_dev {
148148

149149
/* salt for hash table */
150150
static u32 vxlan_salt __read_mostly;
151+
static struct workqueue_struct *vxlan_wq;
151152

152153
/* Virtual Network hash table head */
153154
static inline struct hlist_head *vni_head(struct vxlan_sock *vs, u32 id)
@@ -1631,7 +1632,7 @@ static void vxlan_dellink(struct net_device *dev, struct list_head *head)
16311632

16321633
if (--vs->refcnt == 0) {
16331634
hlist_del_rcu(&vs->hlist);
1634-
schedule_work(&vs->del_work);
1635+
queue_work(vxlan_wq, &vs->del_work);
16351636
}
16361637
}
16371638

@@ -1750,6 +1751,10 @@ static int __init vxlan_init_module(void)
17501751
{
17511752
int rc;
17521753

1754+
vxlan_wq = alloc_workqueue("vxlan", 0, 0);
1755+
if (!vxlan_wq)
1756+
return -ENOMEM;
1757+
17531758
get_random_bytes(&vxlan_salt, sizeof(vxlan_salt));
17541759

17551760
rc = register_pernet_device(&vxlan_net_ops);
@@ -1765,6 +1770,7 @@ static int __init vxlan_init_module(void)
17651770
out2:
17661771
unregister_pernet_device(&vxlan_net_ops);
17671772
out1:
1773+
destroy_workqueue(vxlan_wq);
17681774
return rc;
17691775
}
17701776
late_initcall(vxlan_init_module);
@@ -1773,6 +1779,7 @@ static void __exit vxlan_cleanup_module(void)
17731779
{
17741780
unregister_pernet_device(&vxlan_net_ops);
17751781
rtnl_link_unregister(&vxlan_link_ops);
1782+
destroy_workqueue(vxlan_wq);
17761783
rcu_barrier();
17771784
}
17781785
module_exit(vxlan_cleanup_module);

0 commit comments

Comments
 (0)