From: Steven Rostedt Date: Thu, 20 Feb 2025 20:20:11 +0000 (-0500) Subject: ftrace: Do not add duplicate entries in subops manager ops X-Git-Tag: v6.1.130~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aecca7b4592a9e8d69a85dfcf9c8e5cac95a3fa2;p=thirdparty%2Fkernel%2Fstable.git ftrace: Do not add duplicate entries in subops manager ops commit 8eb4b09e0bbd30981305643229fe7640ad41b667 upstream. Check if a function is already in the manager ops of a subops. A manager ops contains multiple subops, and if two or more subops are tracing the same function, the manager ops only needs a single entry in its hash. Cc: stable@vger.kernel.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Sven Schnelle Cc: Vasily Gorbik Cc: Alexander Gordeev Link: https://lore.kernel.org/20250220202055.226762894@goodmis.org Fixes: 4f554e955614f ("ftrace: Add ftrace_set_filter_ips function") Tested-by: Heiko Carstens Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 55cc0e67a02e3..f252fb71a9333 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5108,6 +5108,9 @@ __ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove) return -ENOENT; free_hash_entry(hash, entry); return 0; + } else if (__ftrace_lookup_ip(hash, ip) != NULL) { + /* Already exists */ + return 0; } return add_hash_entry(hash, ip);