Skip to content

Commit 501e4bb

Browse files
ChiWu-Zeropcmoore
authored andcommitted
audit: use time_after to compare time
Using time_{*} macro to compare time is better Signed-off-by: wuchi <wuchi.zero@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent c3f3ea8 commit 501e4bb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

kernel/audit.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ static inline int audit_rate_check(void)
321321
static DEFINE_SPINLOCK(lock);
322322
unsigned long flags;
323323
unsigned long now;
324-
unsigned long elapsed;
325324
int retval = 0;
326325

327326
if (!audit_rate_limit) return 1;
@@ -330,9 +329,8 @@ static inline int audit_rate_check(void)
330329
if (++messages < audit_rate_limit) {
331330
retval = 1;
332331
} else {
333-
now = jiffies;
334-
elapsed = now - last_check;
335-
if (elapsed > HZ) {
332+
now = jiffies;
333+
if (time_after(now, last_check + HZ)) {
336334
last_check = now;
337335
messages = 0;
338336
retval = 1;
@@ -366,7 +364,7 @@ void audit_log_lost(const char *message)
366364
if (!print) {
367365
spin_lock_irqsave(&lock, flags);
368366
now = jiffies;
369-
if (now - last_msg > HZ) {
367+
if (time_after(now, last_msg + HZ)) {
370368
print = 1;
371369
last_msg = now;
372370
}

0 commit comments

Comments
 (0)