diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 6d3e4821b02d..5a4ae0845bac 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -479,6 +479,7 @@ struct net *copy_net_ns(unsigned long flags,
 
 	if (rv < 0) {
 put_userns:
+		key_remove_domain(net->key_domain);
 		put_user_ns(user_ns);
 		net_drop_ns(net);
 dec_ucounts: