[RFC PATCH 5/5] audit: drop BUG_ON() from audit_log_XXX()

Paul Moore <[email protected]> Fri, 24 Jul 2026 15:56:23 -0400
Newsgroups org.kernel.vger.audit
Message-ID <[email protected]>
We can easily drop the BUG_ON()s from the audit_log_XXX() helpers and
simply return to the caller as we do if we are passed a NULL
audit_buffer.

Reviewed-by: Ricardo Robaina <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
---
 kernel/audit.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 9e10adf21c76..f832c297fb33 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -2027,10 +2027,9 @@ void audit_log_vformat(struct audit_buffer *ab, const char *fmt, va_list args)
 	struct sk_buff *skb;
 	va_list args2;
 
-	if (!ab)
+	if (!ab || !ab->skb)
 		return;
 
-	BUG_ON(!ab->skb);
 	skb = ab->skb;
 	avail = skb_tailroom(skb);
 	va_copy(args2, args);
@@ -2086,10 +2085,9 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
 	unsigned char *ptr;
 	struct sk_buff *skb;
 
-	if (!ab || len <= 0)
+	if (!ab || !ab->skb || len <= 0)
 		return;
 
-	BUG_ON(!ab->skb);
 	skb = ab->skb;
 	avail = skb_tailroom(skb);
 
@@ -2122,10 +2120,9 @@ void audit_log_n_string(struct audit_buffer *ab, const char *string,
 	unsigned char *ptr;
 	struct sk_buff *skb;
 
-	if (!ab || len <= 0)
+	if (!ab || !ab->skb || len <= 0)
 		return;
 
-	BUG_ON(!ab->skb);
 	skb = ab->skb;
 	avail = skb_tailroom(skb);
 
-- 
2.55.0