diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-01-31 22:10:59 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-01-31 22:10:59 +0100 |
commit | 298a2d87518ec01bb36070fafe31da7746556db0 (patch) | |
tree | 7598b4a8b90fa7f0d5e319f29bd7d5c13fbcc282 | |
parent | Merge branch 'for-4.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/gi... (diff) | |
parent | percpu-refcount: fix reference leak during percpu-atomic transition (diff) | |
download | linux-298a2d87518ec01bb36070fafe31da7746556db0.tar.xz linux-298a2d87518ec01bb36070fafe31da7746556db0.zip |
Merge branch 'for-4.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
Pull percpu fix from Tejun Heo:
"Douglas found and fixed a ref leak bug in percpu_ref_tryget[_live]().
The bug is caused by storing the return value of atomic_long_inc_not_zero()
into an int temp variable before returning it as a bool. The interim
cast to int loses the upper bits and can lead to false negatives. As
percpu_ref uses a high bit to mark a draining counter, this can happen
relatively easily.
Fixed by using bool for the temp variable"
* 'for-4.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
percpu-refcount: fix reference leak during percpu-atomic transition
-rw-r--r-- | include/linux/percpu-refcount.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index 1c7eec09e5eb..3a481a49546e 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h @@ -204,7 +204,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref) static inline bool percpu_ref_tryget(struct percpu_ref *ref) { unsigned long __percpu *percpu_count; - int ret; + bool ret; rcu_read_lock_sched(); @@ -238,7 +238,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref) static inline bool percpu_ref_tryget_live(struct percpu_ref *ref) { unsigned long __percpu *percpu_count; - int ret = false; + bool ret = false; rcu_read_lock_sched(); |