Skip to content

Commit

Permalink
[NET]: proto_unregister: fix sleeping while atomic
Browse files Browse the repository at this point in the history
proto_unregister holds a lock while calling kmem_cache_destroy, which
can sleep.

Noticed by Daniele Orlandi <daniele@orlandi.com>.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Sep 7, 2005
1 parent 48bc41a commit 0a3f435
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,8 @@ EXPORT_SYMBOL(proto_register);
void proto_unregister(struct proto *prot)
{
write_lock(&proto_list_lock);
list_del(&prot->node);
write_unlock(&proto_list_lock);

if (prot->slab != NULL) {
kmem_cache_destroy(prot->slab);
Expand All @@ -1550,9 +1552,6 @@ void proto_unregister(struct proto *prot)
kfree(name);
prot->twsk_slab = NULL;
}

list_del(&prot->node);
write_unlock(&proto_list_lock);
}

EXPORT_SYMBOL(proto_unregister);
Expand Down

0 comments on commit 0a3f435

Please sign in to comment.