Skip to content

Commit 3bfa641

Browse files
larkmjcgregkh
authored andcommitted
MIPS: fix truncation in __cmpxchg_small for short values
commit 94ee12b upstream. __cmpxchg_small erroneously uses u8 for load comparison which can be either char or short. This patch changes the local variable 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 <patches@groups.riscv.org> Cc: Linux RISC-V <linux-riscv@lists.infradead.org> Cc: Linux MIPS <linux-mips@linux-mips.org> Signed-off-by: Michael Clark <michaeljclark@mac.com> [paul.burton@mips.com: - Fix varialble typo per Jonas Gorski. - Consolidate load variable with other declarations.] Signed-off-by: Paul Burton <paul.burton@mips.com> Fixes: 3ba7f44 ("MIPS: cmpxchg: Implement 1 byte & 2 byte cmpxchg()") Cc: stable@vger.kernel.org # v4.13+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 527cabf commit 3bfa641

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎arch/mips/kernel/cmpxchg.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ unsigned long __xchg_small(volatile void *ptr, unsigned long val, unsigned int s
5454
unsigned long __cmpxchg_small(volatile void *ptr, unsigned long old,
5555
unsigned long new, unsigned int size)
5656
{
57-
u32 mask, old32, new32, load32;
57+
u32 mask, old32, new32, load32, load;
5858
volatile u32 *ptr32;
5959
unsigned int shift;
60-
u8 load;
6160

6261
/* Check that ptr is naturally aligned */
6362
WARN_ON((unsigned long)ptr & (size - 1));

0 commit comments

Comments
 (0)