[PATCH 3/3] MIPS: fix truncation in __cmpxchg_small for short values
Michael Clark <[email protected]> Mon, 11 Feb 2019 17:38:29 +1300
| Newsgroups | gmane.linux.ports.riscv,gmane.linux.ports.mips.general |
|---|---|
| Message-ID | <[email protected]> |
__cmpxchg_small erroneously uses u8 for load comparison which can be either char or short. This patch changes the local varialble to u32 which is sufficiently sized, as the loaded value is already masked and shifted appropriately. Using an integer size avoids any unnecessary canonicalization from use of non native widths. This patch is part of a series that adapts the MIPS small word atomics code for xchg and cmpxchg on short and char to RISC-V. Cc: RISC-V Patches <[email protected]> Cc: Linux RISC-V <[email protected]> Cc: Linux MIPS <[email protected]> Signed-off-by: Michael Clark <[email protected]> --- arch/mips/kernel/cmpxchg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kernel/cmpxchg.c b/arch/mips/kernel/cmpxchg.c index 0b9535bc2c53..1169958fd748 100644 --- a/arch/mips/kernel/cmpxchg.c +++ b/arch/mips/kernel/cmpxchg.c @@ -57,7 +57,7 @@ unsigned long __cmpxchg_small(volatile void *ptr, unsigned long old, u32 mask, old32, new32, load32; volatile u32 *ptr32; unsigned int shift; - u8 load; + u32 load; /* Check that ptr is naturally aligned */ WARN_ON((unsigned long)ptr & (size - 1)); -- 2.17.1