]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: futex: Restore oldval initialization to work around buggy compilers
authorNathan Chancellor <natechancellor@gmail.com>
Wed, 17 Apr 2019 07:21:21 +0000 (00:21 -0700)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 18 Apr 2019 17:17:08 +0000 (18:17 +0100)
commit3ff276de9edfce57d88d841695f00f9d35ae3642
treee62ff416b393abf3f39ab1096683508cd8fb661a
parent72339f3f27fcd78a0b0a8944c1ad9882bfa8fb5a
arm64: futex: Restore oldval initialization to work around buggy compilers

Commit 2c6482567488 ("arm64: futex: Fix FUTEX_WAKE_OP atomic ops with
non-zero result value") removed oldval's zero initialization in
arch_futex_atomic_op_inuser because it is not necessary. Unfortunately,
Android's arm64 GCC 4.9.4 [1] does not agree:

../kernel/futex.c: In function 'do_futex':
../kernel/futex.c:1658:17: warning: 'oldval' may be used uninitialized
in this function [-Wmaybe-uninitialized]
   return oldval == cmparg;
                 ^
In file included from ../kernel/futex.c:73:0:
../arch/arm64/include/asm/futex.h:53:6: note: 'oldval' was declared here
  int oldval, ret, tmp;
      ^

GCC fails to follow that when ret is non-zero, futex_atomic_op_inuser
returns right away, avoiding the uninitialized use that it claims.
Restoring the zero initialization works around this issue.

[1]: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/

Cc: stable@vger.kernel.org
Fixes: 2c6482567488 ("arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/futex.h