--- a/arch/arm/swapcontext.S
+++ b/arch/arm/swapcontext.S
@@ -17,10 +17,12 @@ ALIAS(__swapcontext, libucontext_swapcon
 
 FUNC(libucontext_swapcontext)
 	/* copy all of the current registers into the ucontext structure */
-	add	r2, r0, #REG_OFFSET(0)
-	stmia	r2, {r0-r12}
 	str	r13, [r0,#REG_OFFSET(13)]
 	str	r14, [r0,#REG_OFFSET(15)]
+	add	r2, r0, #REG_OFFSET(0)
+	/* copy r0 with value 0 to indicate success (return value 0) */
+	mov r0, #0
+	stmia	r2, {r0-r12}
 
 	/* load new registers from the second ucontext structure */
 	add	r14, r1, #REG_OFFSET(0)
