Commit 2716eaf4 authored by Steven Rostedt's avatar Steven Rostedt Committed by Wentao Guan
Browse files

ftrace: Do not add duplicate entries in subops manager ops

stable inclusion
from stable-v6.6.80
commit 59bdc12fe980a37fa00fe2ec92933b03986f91dc
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBXANC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=59bdc12fe980a37fa00fe2ec92933b03986f91dc

--------------------------------

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 <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Link: https://lore.kernel.org/20250220202055.226762894@goodmis.org


Fixes: 4f554e95 ("ftrace: Add ftrace_set_filter_ips function")
Tested-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Reviewed-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 59bdc12fe980a37fa00fe2ec92933b03986f91dc)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent d162d16d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5233,6 +5233,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;
	}

	entry = add_hash_entry(hash, ip);