Messages in this thread | | | Date | Fri, 27 Jan 2017 17:09:58 -0500 | From | Tejun Heo <> | Subject | Re: [PATCH 1/1] percpu-refcount: fix reference leak during percpu-atomic transition |
| |
Hello, Douglas.
On Fri, Jan 27, 2017 at 02:59:08PM -0600, Douglas Miller wrote: > @@ -212,7 +212,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref) > this_cpu_inc(*percpu_count); > ret = true; > } else { > - ret = atomic_long_inc_not_zero(&ref->count); > + ret = (atomic_long_inc_not_zero(&ref->count) != 0); > } > > rcu_read_unlock_sched(); > @@ -246,7 +246,7 @@ static inline bool percpu_ref_tryget_live(struct percpu_ref *ref) > this_cpu_inc(*percpu_count); > ret = true; > } else if (!(ref->percpu_count_ptr & __PERCPU_REF_DEAD)) { > - ret = atomic_long_inc_not_zero(&ref->count); > + ret = (atomic_long_inc_not_zero(&ref->count) != 0);
Ugh.... Damn it. This is why we use bools instead of ints for these things. For some reason, we're returning bools but using an integer variable to cache the result. :(
Can you please convert the local variable to bool instead?
Thanks a lot for spotting this.
-- tejun
| |