Skip to content

Commit 90af90d

Browse files
Alexey Dobriyantorvalds
authored andcommitted
nsproxy: extract create_nsproxy()
clone_nsproxy() does useless copying of old nsproxy -- every pointer will be rewritten to new ns or to old ns. Remove copying, rename clone_nsproxy(), create_nsproxy() will be used by C/R code to create fresh nsproxy on restart. Signed-off-by: Alexey Dobriyan <[email protected]> Acked-by: Serge Hallyn <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 612ce47 commit 90af90d

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

kernel/nsproxy.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,14 @@ static struct kmem_cache *nsproxy_cachep;
2626

2727
struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
2828

29-
/*
30-
* creates a copy of "orig" with refcount 1.
31-
*/
32-
static inline struct nsproxy *clone_nsproxy(struct nsproxy *orig)
29+
static inline struct nsproxy *create_nsproxy(void)
3330
{
34-
struct nsproxy *ns;
31+
struct nsproxy *nsproxy;
3532

36-
ns = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
37-
if (ns) {
38-
memcpy(ns, orig, sizeof(struct nsproxy));
39-
atomic_set(&ns->count, 1);
40-
}
41-
return ns;
33+
nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
34+
if (nsproxy)
35+
atomic_set(&nsproxy->count, 1);
36+
return nsproxy;
4237
}
4338

4439
/*
@@ -52,7 +47,7 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
5247
struct nsproxy *new_nsp;
5348
int err;
5449

55-
new_nsp = clone_nsproxy(tsk->nsproxy);
50+
new_nsp = create_nsproxy();
5651
if (!new_nsp)
5752
return ERR_PTR(-ENOMEM);
5853

0 commit comments

Comments
 (0)