lkml.org 
[lkml]   [2017]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2017-01-27 23:18    [W:0.151 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site