public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] audit: Quit audit_free_names() early if name list empty
@ 2026-01-21  2:35 Waiman Long
  2026-01-21  2:35 ` [PATCH 2/2] audit: Call path_{put,get}() in audit_alloc_name()/audit_free_names() only when necessary Waiman Long
  2026-01-21  3:11 ` [PATCH 1/2] audit: Quit audit_free_names() early if name list empty Al Viro
  0 siblings, 2 replies; 6+ messages in thread
From: Waiman Long @ 2026-01-21  2:35 UTC (permalink / raw)
  To: Paul Moore, Eric Paris, Christian Brauner, Al Viro
  Cc: linux-kernel, audit, Richard Guy Briggs, Ricardo Robaina,
	Waiman Long

Optimize audit_free_names() by quitting early if the name list is empty.
This eliminates the need to acquire and release the fs_struct spinlock
in path_put().

Signed-off-by: Waiman Long <longman@redhat.com>
---
 kernel/auditsc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index dd0563a8e0be..824b6fd98561 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -931,6 +931,9 @@ static inline void audit_free_names(struct audit_context *context)
 {
 	struct audit_names *n, *next;
 
+	if (list_empty(&context->names_list))
+		return;	/* audit_alloc_name() has not been called */
+
 	list_for_each_entry_safe(n, next, &context->names_list, list) {
 		list_del(&n->list);
 		if (n->name)
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-21 15:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21  2:35 [PATCH 1/2] audit: Quit audit_free_names() early if name list empty Waiman Long
2026-01-21  2:35 ` [PATCH 2/2] audit: Call path_{put,get}() in audit_alloc_name()/audit_free_names() only when necessary Waiman Long
2026-01-21  3:11 ` [PATCH 1/2] audit: Quit audit_free_names() early if name list empty Al Viro
2026-01-21  4:08   ` Waiman Long
2026-01-21  5:26     ` Al Viro
2026-01-21 15:09       ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox