Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 331b6d8c authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

locking/barriers: Validate lockless_dereference() is used on a pointer type



Use the type to validate the argument @p is indeed a pointer type.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160522104827.GP3193@twins.programming.kicks-ass.net


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent a461d587
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -545,10 +545,14 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 * Similar to rcu_dereference(), but for situations where the pointed-to
 * object's lifetime is managed by something other than RCU.  That
 * "something other" might be reference counting or simple immortality.
 *
 * The seemingly unused void * variable is to validate @p is indeed a pointer
 * type. All pointer types silently cast to void *.
 */
#define lockless_dereference(p) \
({ \
	typeof(p) _________p1 = READ_ONCE(p); \
	__maybe_unused const void * const _________p2 = _________p1; \
	smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
	(_________p1); \
})