Skip to content

Commit bcab1dd

Browse files
Kirill Tkhaidavem330
authored andcommitted
net: Move mutex_unlock() in cleanup_net() up
net_sem protects from pernet_list changing, while ops_free_list() makes simple kfree(), and it can't race with other pernet_operations callbacks. So we may release net_mutex earlier then it was. Signed-off-by: Kirill Tkhai <[email protected]> Acked-by: Andrei Vagin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a57feb commit bcab1dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/core/net_namespace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,12 @@ static void cleanup_net(struct work_struct *work)
522522
list_for_each_entry_reverse(ops, &pernet_list, list)
523523
ops_exit_list(ops, &net_exit_list);
524524

525+
mutex_unlock(&net_mutex);
526+
525527
/* Free the net generic variables */
526528
list_for_each_entry_reverse(ops, &pernet_list, list)
527529
ops_free_list(ops, &net_exit_list);
528530

529-
mutex_unlock(&net_mutex);
530531
up_read(&net_sem);
531532

532533
/* Ensure there are no outstanding rcu callbacks using this

0 commit comments

Comments
 (0)