Re: [PATCH 1/1] percpu-refcount: fix reference leak during percpu-atomic transition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux