[PATCH] m68k: cmpxchg: Fix return value for default case in __arch_xchg()

Thorsten Blum posted 1 patch 1 year, 5 months ago
arch/m68k/include/asm/cmpxchg.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] m68k: cmpxchg: Fix return value for default case in __arch_xchg()
Posted by Thorsten Blum 1 year, 5 months ago
The return value of __invalid_xchg_size() is assigned to tmp instead of
the return variable x. Assign it to x instead.

Fixes: 803f69144f0d ("Disintegrate asm/system.h for M68K")
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 arch/m68k/include/asm/cmpxchg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/cmpxchg.h b/arch/m68k/include/asm/cmpxchg.h
index d7f3de9c5d6f..4ba14f3535fc 100644
--- a/arch/m68k/include/asm/cmpxchg.h
+++ b/arch/m68k/include/asm/cmpxchg.h
@@ -32,7 +32,7 @@ static inline unsigned long __arch_xchg(unsigned long x, volatile void * ptr, in
 		x = tmp;
 		break;
 	default:
-		tmp = __invalid_xchg_size(x, ptr, size);
+		x = __invalid_xchg_size(x, ptr, size);
 		break;
 	}
 
-- 
2.45.2
Re: [PATCH] m68k: cmpxchg: Fix return value for default case in __arch_xchg()
Posted by Geert Uytterhoeven 1 year, 5 months ago
Hi Thorsten,

On Tue, Jul 2, 2024 at 5:42 AM Thorsten Blum <thorsten.blum@toblux.com> wrote:
> The return value of __invalid_xchg_size() is assigned to tmp instead of
> the return variable x. Assign it to x instead.

Thanks for your patch!

> Fixes: 803f69144f0d ("Disintegrate asm/system.h for M68K")

That is not the right commit.  The issue was introduced before:
Fixes: 2501cf768e4009a0 ("m68k: Fix xchg/cmpxchg to fail to link if
given an inappropriate pointer")

> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

> --- a/arch/m68k/include/asm/cmpxchg.h
> +++ b/arch/m68k/include/asm/cmpxchg.h
> @@ -32,7 +32,7 @@ static inline unsigned long __arch_xchg(unsigned long x, volatile void * ptr, in
>                 x = tmp;
>                 break;
>         default:
> -               tmp = __invalid_xchg_size(x, ptr, size);
> +               x = __invalid_xchg_size(x, ptr, size);
>                 break;
>         }

Although this was not a real bug (__invalid_xchg_size() does not exist,
but is referenced to cause a deliberate link error), it is good to
clean this up.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k tree for v6.11.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH] m68k: cmpxchg: Fix return value for default case in __arch_xchg()
Posted by Thorsten Blum 1 year, 5 months ago
On 2. Jul 2024, at 00:21, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> 
> Hi Thorsten,
> 
> On Tue, Jul 2, 2024 at 5:42 AM Thorsten Blum <thorsten.blum@toblux.com> wrote:
>> The return value of __invalid_xchg_size() is assigned to tmp instead of
>> the return variable x. Assign it to x instead.
> 
> Thanks for your patch!
> 
>> Fixes: 803f69144f0d ("Disintegrate asm/system.h for M68K")
> 
> That is not the right commit.  The issue was introduced before:
> Fixes: 2501cf768e4009a0 ("m68k: Fix xchg/cmpxchg to fail to link if
> given an inappropriate pointer")
> 
>> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> 
>> --- a/arch/m68k/include/asm/cmpxchg.h
>> +++ b/arch/m68k/include/asm/cmpxchg.h
>> @@ -32,7 +32,7 @@ static inline unsigned long __arch_xchg(unsigned long x, volatile void * ptr, in
>>                x = tmp;
>>                break;
>>        default:
>> -               tmp = __invalid_xchg_size(x, ptr, size);
>> +               x = __invalid_xchg_size(x, ptr, size);
>>                break;
>>        }
> 
> Although this was not a real bug (__invalid_xchg_size() does not exist,
> but is referenced to cause a deliberate link error), it is good to
> clean this up.

Thank you for explaining this. I was already wondering why I couldn't 
find the function definition.

Thorsten