[Devel] [PATCH rh7] net-namespace: Don't forget to put_ve on error path

Cyrill Gorcunov gorcunov at odin.com
Mon May 18 07:51:02 PDT 2015


If error happened during new net-namespace creation we might
end up having VE reference taken and never put back.

 | copy_net_ns
 |  setup_net
 |   ...
 |   net->owner_ve = get_ve(get_exec_env());
 |   ...
 |   error = ops_init(ops, net);
 |   if (error < 0)
 |    goto out_undo;
 |   ...
 |   return error;
 |  put_user_ns(user_ns);
 |  net_drop_ns(net);
 |   net_free(ns);
 |    kfree(net->gen);
 |    kmem_cache_free(net_cachep, net);

So lets call for put_ve to balance.

Signed-off-by: Cyrill Gorcunov <gorcunov at odin.com>
CC: Vladimir Davydov <vdavydov at odin.com>
CC: Konstantin Khorenko <khorenko at odin.com>
CC: Andrey Vagin <avagin at odin.com>
---
 net/core/net_namespace.c |    3 +++
 1 file changed, 3 insertions(+)

Index: linux-pcs7.git/net/core/net_namespace.c
===================================================================
--- linux-pcs7.git.orig/net/core/net_namespace.c
+++ linux-pcs7.git/net/core/net_namespace.c
@@ -192,6 +192,9 @@ out_undo:
 		ops_free_list(ops, &net_exit_list);
 
 	rcu_barrier();
+#ifdef CONFIG_VE
+	put_ve(net->owner_ve);
+#endif
 	goto out;
 }
 



More information about the Devel mailing list