x86: atomic64: Fix unclean type use in atomic64_xchg()
authorIngo Molnar <mingo@elte.hu>
Fri, 3 Jul 2009 11:02:39 +0000 (13:02 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 3 Jul 2009 11:26:46 +0000 (13:26 +0200)
Linus noticed that atomic64_xchg() uses atomic_read(), which
happens to work because atomic_read() is a macro so the
.counter value gets u64-read on 32-bit too - but this is really
bogus and serious bugs are waiting to happen.

Fix atomic64_xchg() to use __atomic64_read() instead.

No code changed:

arch/x86/lib/atomic64_32.o:

   text    data     bss     dec     hex filename
    435       0       0     435     1b3 atomic64_32.o.before
    435       0       0     435     1b3 atomic64_32.o.after

md5:
   bd8ab95e69c93518578bfaf0ea3be4d9  atomic64_32.o.before.asm
   bd8ab95e69c93518578bfaf0ea3be4d9  atomic64_32.o.after.asm

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
LKML-Reference: <alpine.LFD.2.01.0907021653030.3210@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/lib/atomic64_32.c

index a910238a77604298f5f8db997ee17b3e3e079321..fd28fd3fb742a93cf4da957e3a16f7a05199e1be 100644 (file)
@@ -36,7 +36,7 @@ u64 atomic64_xchg(atomic64_t *ptr, u64 new_val)
        u64 old_val;
 
        do {
-               old_val = atomic_read(ptr);
+               old_val = __atomic64_read(ptr);
        } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);
 
        return old_val;