Blob Blame History Raw
From: Jiri Olsa <jolsa@kernel.org>
Date: Wed, 16 Mar 2022 13:24:08 +0100
Subject: kallsyms: Skip the name search for empty string
Patch-mainline: v5.18-rc1
Git-commit: aecf489f2ce51436402818c96639ed6303b540f8
References: jsc#PED-1377

When kallsyms_lookup_name is called with empty string,
it will do futile search for it through all the symbols.

Skipping the search for empty string.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220316122419.933957-3-jolsa@kernel.org
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
 kernel/kallsyms.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -192,6 +192,10 @@ unsigned long kallsyms_lookup_name(const
 	unsigned long i;
 	unsigned int off;
 
+	/* Skip the search for empty string. */
+	if (!*name)
+		return 0;
+
 	for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
 		off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf));