Skip to contentSkip to conversation

audit: use time_after to compare time

PATCH Applied wuchi 2 participants 2 messages Aug 29, 2022 Audit

lore
Share & tools
lore

wuchi

author
#0 lore raw

PATCH 1/1 audit: use time_after to compare time

Using time_{*} macro to compare time is better

---
 kernel/audit.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/audit.c +3 -5
index a75978ae38ad..9bc0b0301198 100644
@@ -321,7 +321,6 @@ static inline int audit_rate_check(void)
 	static DEFINE_SPINLOCK(lock);
 	unsigned long		flags;
 	unsigned long		now;
-	unsigned long		elapsed;
 	int			retval	   = 0;
 
 	if (!audit_rate_limit) return 1;
@@ -330,9 +329,8 @@ static inline int audit_rate_check(void)
 	if (++messages < audit_rate_limit) {
 		retval = 1;
 	} else {
-		now     = jiffies;
-		elapsed = now - last_check;
-		if (elapsed > HZ) {
+		now = jiffies;
+		if (time_after(now, last_check + HZ)) {
 			last_check = now;
 			messages   = 0;
 			retval     = 1;
@@ -366,7 +364,7 @@ void audit_log_lost(const char *message)
 	if (!print) {
 		spin_lock_irqsave(&lock, flags);
 		now = jiffies;
-		if (now - last_msg > HZ) {
+		if (time_after(now, last_msg + HZ)) {
 			print = 1;
 			last_msg = now;
 		}
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 7 lines · wuchi

Using time_{*} macro to compare time is better

---
 kernel/audit.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Merged into audit/next, thanks!

Signature · 6 lines
paul-moore.com

--
Linux-audit mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/linux-audit