From 9f33cf76407fbbb3465dc77596a27d9dba5a0f97 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 3 Feb 2004 18:46:51 -0800 Subject: [PATCH] [PATCH] copy_namespace ENOMEM fix From: Marcus Alanen The copy_tree() function can return NULL, so this checks for it. --- fs/namespace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index a8ce8f431bb49..c2b8d730e6088 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -817,12 +817,16 @@ int copy_namespace(int flags, struct task_struct *tsk) atomic_set(&new_ns->count, 1); init_rwsem(&new_ns->sem); - new_ns->root = NULL; INIT_LIST_HEAD(&new_ns->list); down_write(&tsk->namespace->sem); /* First pass: copy the tree topology */ new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root); + if (!new_ns->root) { + up_write(&tsk->namespace->sem); + kfree(new_ns); + goto out; + } spin_lock(&vfsmount_lock); list_add_tail(&new_ns->list, &new_ns->root->mnt_list); spin_unlock(&vfsmount_lock); -- 2.53.0