]> git.baikalelectronics.ru Git - kernel.git/commit
s390/lib: fix memcmp and strstr
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 4 Aug 2016 08:24:30 +0000 (10:24 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 8 Aug 2016 13:41:31 +0000 (15:41 +0200)
commit7594a946ee548c2d2eef7ffb5f01bdc5fd74cf20
tree1c95439c4a7f1696fbcaf1a753ccb68e62137b47
parentc98c5f408f1a8558b3ed975521c7d0c0a069c7e5
s390/lib: fix memcmp and strstr

if two string compare equal the clcle instruction will update the
string addresses to point _after_ the string. This might already
be on a different page, so we should not use these pointer to
calculate the difference as in that case the calculation of the
difference can cause oopses.

The return value of memcmp does not need the difference, we
can just reuse the condition code and return for CC=1 (All bytes
compared, first operand low) -1 and for CC=2 (All bytes compared,
first operand high) +1
strstr also does not need the diff.
While fixing this, make the common function clcle "correct on its
own" by using l1 instead of l2 for the first length. strstr will
call this with l2 for both strings.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Fixes: 6a578c57cee5 ("s390/lib: use basic blocks for inline assemblies")
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/lib/string.c