Lines Matching +full:i +full:- +full:leak +full:- +full:current

1 /* SPDX-License-Identifier: GPL-2.0 */
13 * counter and causing 'spurious' use-after-free issues. In order to avoid the
23 * +--------------------------------+----------------+----------------+
24 * <---------- bad value! ---------->
44 * With the current PID limit, if no batched refcounting operations are used and
50 * (UINT_MAX+1-REFCOUNT_SATURATED) / PID_MAX_LIMIT =
55 * given the precise timing details involved with the round-robin scheduling of
82 * because the 1->0 transition indicates no concurrency.
119 * refcount_set - set a refcount's value
125 atomic_set(&r->refs, n); in refcount_set()
129 * refcount_read - get a refcount's value
136 return atomic_read(&r->refs); in refcount_read()
140 bool __refcount_add_not_zero(int i, refcount_t *r, int *oldp) in __refcount_add_not_zero() argument
147 } while (!atomic_try_cmpxchg_relaxed(&r->refs, &old, old + i)); in __refcount_add_not_zero()
152 if (unlikely(old < 0 || old + i < 0)) in __refcount_add_not_zero()
159 * refcount_add_not_zero - add a value to a refcount unless it is 0
160 * @i: the value to add to the refcount
176 static inline __must_check bool refcount_add_not_zero(int i, refcount_t *r) in refcount_add_not_zero() argument
178 return __refcount_add_not_zero(i, r, NULL); in refcount_add_not_zero()
182 void __refcount_add(int i, refcount_t *r, int *oldp) in __refcount_add() argument
184 int old = atomic_fetch_add_relaxed(i, &r->refs); in __refcount_add()
191 else if (unlikely(old < 0 || old + i < 0)) in __refcount_add()
196 * refcount_add - add a value to a refcount
197 * @i: the value to add to the refcount
211 static inline void refcount_add(int i, refcount_t *r) in refcount_add() argument
213 __refcount_add(i, r, NULL); in refcount_add()
222 * refcount_inc_not_zero - increment a refcount unless it is 0
245 * refcount_inc - increment a refcount
253 * Will WARN if the refcount is 0, as this represents a possible use-after-free
262 bool __refcount_sub_and_test(int i, refcount_t *r, int *oldp) in __refcount_sub_and_test() argument
264 int old = atomic_fetch_sub_release(i, &r->refs); in __refcount_sub_and_test()
269 if (old > 0 && old == i) { in __refcount_sub_and_test()
274 if (unlikely(old <= 0 || old - i < 0)) in __refcount_sub_and_test()
281 * refcount_sub_and_test - subtract from a refcount and test if it is 0
282 * @i: amount to subtract from the refcount
286 * ultimately leak on underflow and will fail to decrement when saturated
300 static inline __must_check bool refcount_sub_and_test(int i, refcount_t *r) in refcount_sub_and_test() argument
302 return __refcount_sub_and_test(i, r, NULL); in refcount_sub_and_test()
311 * refcount_dec_and_test - decrement a refcount and test if it is 0
330 int old = atomic_fetch_sub_release(1, &r->refs); in __refcount_dec()
340 * refcount_dec - decrement a refcount