Skip to contentSkip to conversation

fix copy_namespace()

PATCH New Christoph Hellwig 1 participant 1 message Aug 25, 2003

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix copy_namespace()

Originally by aeb, in 2.5 for ages.

Fix far too small kmalloc in copy_namespace and promote errors properly.

fs/namespace.c +1 -1
@@ -763,7 +763,7 @@ int copy_namespace(int flags, struct tas
 		return -EPERM;
 	}
 
-	new_ns = kmalloc(sizeof(struct namespace *), GFP_KERNEL);
+	new_ns = kmalloc(sizeof(struct namespace), GFP_KERNEL);
 	if (!new_ns)
 		goto out;
 
kernel/fork.c +2 -1
@@ -793,7 +793,8 @@ int do_fork(unsigned long clone_flags, u
 		goto bad_fork_cleanup_fs;
 	if (copy_mm(clone_flags, p))
 		goto bad_fork_cleanup_sighand;
-	if (copy_namespace(clone_flags, p))
+	retval = copy_namespace(clone_flags, p);
+	if (retval)
 		goto bad_fork_cleanup_mm;
 	retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs);
 	if (retval)