From b0d56e6c90efeec41cfbce97b973d4516d5db0a3 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Mon, 17 Feb 2014 14:02:06 +0000 Subject: asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_* The asm-generic rwsem implementation directly acceses sem->cnt when performing a __down_read_trylock operation. Whilst this is probably safe on all architectures, we should stick to the atomic_long_* API and use atomic_long_read instead. Signed-off-by: Will Deacon --- include/asm-generic/rwsem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/asm-generic') diff --git a/include/asm-generic/rwsem.h b/include/asm-generic/rwsem.h index bb1e2cdeb..75af612f5 100644 --- a/include/asm-generic/rwsem.h +++ b/include/asm-generic/rwsem.h @@ -41,7 +41,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) { long tmp; - while ((tmp = sem->count) >= 0) { + while ((tmp = atomic_long_read((atomic_long_t *)&sem->count)) >= 0) { if (tmp == cmpxchg(&sem->count, tmp, tmp + RWSEM_ACTIVE_READ_BIAS)) { return 1; -- cgit v1.2.3