aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/lib/string.S
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2010-03-17 06:55:51 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-04-07 04:00:39 -0400
commit637a99022fb119b90fb281715d13172f0394fc12 (patch)
treeecd77d0ce7499bb7af7b7a3cf508010552dcbb39 /arch/powerpc/lib/string.S
parent6d1bdd2afbed74b3adcf3a7aec49e430eeb6c5f3 (diff)
powerpc: Fix handling of strncmp with zero len
Commit 0119536c, which added the assembly version of strncmp to powerpc, mentions that it adds two instructions to the version from boot/string.S to allow it to handle len=0. Unfortunately, it doesn't always return 0 when that is the case. The length is passed in r5, but the return value is passed back in r3. In certain cases, this will happen to work. Otherwise it will pass back the address of the first string as the return value. This patch lifts the len <= 0 handling code from memcpy to handle that case. Reported by: Christian_Sellars@symantec.com Signed-off-by: Jeff Mahoney <jeffm@suse.com> CC: <stable@kernel.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/lib/string.S')
-rw-r--r--arch/powerpc/lib/string.S4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S
index 64e2e499e32a..3ac0cd3a5373 100644
--- a/arch/powerpc/lib/string.S
+++ b/arch/powerpc/lib/string.S
@@ -71,7 +71,7 @@ _GLOBAL(strcmp)
71 71
72_GLOBAL(strncmp) 72_GLOBAL(strncmp)
73 PPC_LCMPI r5,0 73 PPC_LCMPI r5,0
74 beqlr 74 ble- 2f
75 mtctr r5 75 mtctr r5
76 addi r5,r3,-1 76 addi r5,r3,-1
77 addi r4,r4,-1 77 addi r4,r4,-1
@@ -82,6 +82,8 @@ _GLOBAL(strncmp)
82 beqlr 1 82 beqlr 1
83 bdnzt eq,1b 83 bdnzt eq,1b
84 blr 84 blr
852: li r3,0
86 blr
85 87
86_GLOBAL(strlen) 88_GLOBAL(strlen)
87 addi r4,r3,-1 89 addi r4,r3,-1