Skip to content

Commit 8366eb4

Browse files
Kirill TkhaiNagarathnam Muthusamy
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]> (cherry picked from commit bcab1dd) Orabug: 28900385 Signed-off-by: Nagarathnam Muthusamy <[email protected]> Reviewed-by: Darren Kenny <[email protected]>
1 parent 8f25e47 commit 8366eb4

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
@@ -488,11 +488,12 @@ static void cleanup_net(struct work_struct *work)
488488
list_for_each_entry_reverse(ops, &pernet_list, list)
489489
ops_exit_list(ops, &net_exit_list);
490490

491+
mutex_unlock(&net_mutex);
492+
491493
/* Free the net generic variables */
492494
list_for_each_entry_reverse(ops, &pernet_list, list)
493495
ops_free_list(ops, &net_exit_list);
494496

495-
mutex_unlock(&net_mutex);
496497
up_read(&net_sem);
497498

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

0 commit comments

Comments
 (0)