Commit 9f33cf76 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] copy_namespace ENOMEM fix

From: Marcus Alanen <maalanen@ra.abo.fi>

The copy_tree() function can return NULL, so this checks for it.
parent 89076ac4
...@@ -817,12 +817,16 @@ int copy_namespace(int flags, struct task_struct *tsk) ...@@ -817,12 +817,16 @@ int copy_namespace(int flags, struct task_struct *tsk)
atomic_set(&new_ns->count, 1); atomic_set(&new_ns->count, 1);
init_rwsem(&new_ns->sem); init_rwsem(&new_ns->sem);
new_ns->root = NULL;
INIT_LIST_HEAD(&new_ns->list); INIT_LIST_HEAD(&new_ns->list);
down_write(&tsk->namespace->sem); down_write(&tsk->namespace->sem);
/* First pass: copy the tree topology */ /* First pass: copy the tree topology */
new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root); 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); spin_lock(&vfsmount_lock);
list_add_tail(&new_ns->list, &new_ns->root->mnt_list); list_add_tail(&new_ns->list, &new_ns->root->mnt_list);
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment