Skip to content

Commit 3234270

Browse files
committed
ucounts: Use atomic_long_sub_return for clarity
Decrement ucounts using atomic_long_sub_return to make it clear the point is for the ucount to decrease. Not a big deal but it should make it easier to catch bugs. Suggested-by: Yu Zhao <[email protected]> Link: https://lkml.kernel.org/r/87k0iaqkqj.fsf_-_@disp2133 Tested-by: Yu Zhao <[email protected]> Reviewed-by: Alexey Gladkov <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent da70d31 commit 3234270

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/ucount.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ bool dec_rlimit_ucounts(struct ucounts *ucounts, enum ucount_type type, long v)
282282
struct ucounts *iter;
283283
long new = -1; /* Silence compiler warning */
284284
for (iter = ucounts; iter; iter = iter->ns->ucounts) {
285-
long dec = atomic_long_add_return(-v, &iter->ucount[type]);
285+
long dec = atomic_long_sub_return(v, &iter->ucount[type]);
286286
WARN_ON_ONCE(dec < 0);
287287
if (iter == ucounts)
288288
new = dec;
@@ -295,7 +295,7 @@ static void do_dec_rlimit_put_ucounts(struct ucounts *ucounts,
295295
{
296296
struct ucounts *iter, *next;
297297
for (iter = ucounts; iter != last; iter = next) {
298-
long dec = atomic_long_add_return(-1, &iter->ucount[type]);
298+
long dec = atomic_long_sub_return(1, &iter->ucount[type]);
299299
WARN_ON_ONCE(dec < 0);
300300
next = iter->ns->ucounts;
301301
if (dec == 0)
@@ -332,7 +332,7 @@ long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum ucount_type type)
332332
}
333333
return ret;
334334
dec_unwind:
335-
dec = atomic_long_add_return(-1, &iter->ucount[type]);
335+
dec = atomic_long_sub_return(1, &iter->ucount[type]);
336336
WARN_ON_ONCE(dec < 0);
337337
unwind:
338338
do_dec_rlimit_put_ucounts(ucounts, iter, type);

0 commit comments

Comments
 (0)