summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/misc_32.S
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@us.ibm.com>2008-10-07 08:10:03 +0200
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-10 06:55:18 +0200
commit41c2e949cb7b80c5a6247c7df97759953b0f71b5 (patch)
treec8ba92fa5cd1dc7f6293552704e639135008c343 /arch/powerpc/kernel/misc_32.S
parentpowerpc/cell/oprofile: Fix test on overlay_tbl_offset in vma_map (diff)
downloadlinux-41c2e949cb7b80c5a6247c7df97759953b0f71b5.tar.xz
linux-41c2e949cb7b80c5a6247c7df97759953b0f71b5.zip
powerpc: Fix error path in kernel_thread function
The powerpc 32-bit and 64-bit kernel_thread functions don't properly propagate errors being returned by the clone syscall. (In the case of error, the syscall exit code returns a positive errno in r3 and sets the CR0[SO] bit.) This patch fixes that by negating r3 if CR0[SO] is set after the syscall. Signed-off-by: Josh Poimboeuf <jpoimboe@us.ibm.com> Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com> Acked-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/misc_32.S')
-rw-r--r--arch/powerpc/kernel/misc_32.S8
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index e9c8ab6eabfe..6a9b4bf0d173 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -900,8 +900,10 @@ _GLOBAL(kernel_thread)
li r4,0 /* new sp (unused) */
li r0,__NR_clone
sc
- cmpwi 0,r3,0 /* parent or child? */
- bne 1f /* return if parent */
+ bns+ 1f /* did system call indicate error? */
+ neg r3,r3 /* if so, make return code negative */
+1: cmpwi 0,r3,0 /* parent or child? */
+ bne 2f /* return if parent */
li r0,0 /* make top-level stack frame */
stwu r0,-16(r1)
mtlr r30 /* fn addr in lr */
@@ -911,7 +913,7 @@ _GLOBAL(kernel_thread)
li r0,__NR_exit /* exit if function returns */
li r3,0
sc
-1: lwz r30,8(r1)
+2: lwz r30,8(r1)
lwz r31,12(r1)
addi r1,r1,16
blr