]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] copy_namespace ENOMEM fix
authorAndrew Morton <akpm@osdl.org>
Wed, 4 Feb 2004 02:46:51 +0000 (18:46 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 4 Feb 2004 02:46:51 +0000 (18:46 -0800)
From: Marcus Alanen <maalanen@ra.abo.fi>

The copy_tree() function can return NULL, so this checks for it.

fs/namespace.c

index a8ce8f431bb49e923268e544d534e876f1cc6e48..c2b8d730e6088b046e6c01bda2312b057ee32355 100644 (file)
@@ -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);