aboutsummaryrefslogtreecommitdiff
path: root/include/asm-generic/rwsem.h
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2014-02-17 14:02:06 +0000
committerMoyster <oysterized@gmail.com>2016-09-13 13:23:07 +0200
commitb0d56e6c90efeec41cfbce97b973d4516d5db0a3 (patch)
tree61a61cda9329ec83f24de12ca72db8f04a7b5496 /include/asm-generic/rwsem.h
parentff8474388aa56e36f638c6d08f5ec9b48c76e74d (diff)
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 <will.deacon@arm.com>
Diffstat (limited to 'include/asm-generic/rwsem.h')
-rw-r--r--include/asm-generic/rwsem.h2
1 files changed, 1 insertions, 1 deletions
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;