diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index cbff7d94b993ec941197c99af3118350e7c95445..a3b7d965e9c019897ebfee816d9e8f1e5acb1b12 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -135,6 +135,7 @@ static int net_assign_generic(struct net *net, unsigned int id, void *data) static int ops_init(const struct pernet_operations *ops, struct net *net) { + struct net_generic *ng; int err = -ENOMEM; void *data = NULL; @@ -153,7 +154,13 @@ static int ops_init(const struct pernet_operations *ops, struct net *net) if (!err) return 0; + if (ops->id && ops->size) { cleanup: + ng = rcu_dereference_protected(net->gen, + lockdep_is_held(&pernet_ops_rwsem)); + ng->ptr[*ops->id] = NULL; + } + kfree(data); out: