diff options
author | Nina Schoetterl-Glausch <nsg@linux.ibm.com> | 2024-01-11 10:48:05 +0100 |
---|---|---|
committer | Janosch Frank <frankja@linux.ibm.com> | 2024-02-23 14:02:27 +0100 |
commit | 00de073e2420df02ac0f1a19dbfb60ff8eb198be (patch) | |
tree | 024d4f7cb3eb4c058066997412b64fd45e5cdbde /tools/testing | |
parent | KVM: s390: only deliver the set service event bits (diff) | |
download | linux-00de073e2420df02ac0f1a19dbfb60ff8eb198be.tar.xz linux-00de073e2420df02ac0f1a19dbfb60ff8eb198be.zip |
KVM: s390: selftest: memop: Fix undefined behavior
If an integer's type has x bits, shifting the integer left by x or more
is undefined behavior.
This can happen in the rotate function when attempting to do a rotation
of the whole value by 0.
Fixes: 0dd714bfd200 ("KVM: s390: selftest: memop: Add cmpxchg tests")
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Link: https://lore.kernel.org/r/20240111094805.363047-1-nsg@linux.ibm.com
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Message-Id: <20240111094805.363047-1-nsg@linux.ibm.com>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/kvm/s390x/memop.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c index bb3ca9a5d731..4ec8d0181e8d 100644 --- a/tools/testing/selftests/kvm/s390x/memop.c +++ b/tools/testing/selftests/kvm/s390x/memop.c @@ -489,6 +489,8 @@ static __uint128_t rotate(int size, __uint128_t val, int amount) amount = (amount + bits) % bits; val = cut_to_size(size, val); + if (!amount) + return val; return (val << (bits - amount)) | (val >> amount); } |