[tip: locking/urgent] bit_spinlock: Fix the __bitlock() macro definition

tip-bot2 for Bart Van Assche posted 1 patch 11 hours ago
There is a newer version of this series
include/linux/bit_spinlock.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[tip: locking/urgent] bit_spinlock: Fix the __bitlock() macro definition
Posted by tip-bot2 for Bart Van Assche 11 hours ago
The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     389327330cfe23adce88b55ee78c0d21fed9957e
Gitweb:        https://git.kernel.org/tip/389327330cfe23adce88b55ee78c0d21fed9957e
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Wed, 18 Nov 2026 15:09:57 -08:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Sun, 22 Nov 2026 15:59:42 +01:00

bit_spinlock: Fix the __bitlock() macro definition

Surround the 'bitnum' argument and the entire __bitlock() macro expansion
with parentheses because 'bitnum' could be an expression that includes an
operator with a lower precedence than the addition operator (e.g. the
exclusive-or operator) and to prevent operator precedence issues in
callers.

Fixes: eb7d96a13bf4 ("bit_spinlock: Support Clang's context analysis")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Marco Elver <elver@google.com>
Link: https://patch.msgid.link/38cdec9322fa710f84c018e0b318894c6234c411.1795043161.git.bvanassche@acm.org
---
 include/linux/bit_spinlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h
index 7869a6e..c31d4f4 100644
--- a/include/linux/bit_spinlock.h
+++ b/include/linux/bit_spinlock.h
@@ -17,7 +17,7 @@
  * static analysis can use.
  */
 context_lock_struct(__context_bitlock) { };
-#define __bitlock(bitnum, addr) (struct __context_bitlock *)(bitnum + (addr))
+#define __bitlock(bitnum, addr) ((struct __context_bitlock *)((bitnum) + (addr)))
 
 /*
  *  bit-based spin_lock()