linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kallsyms: optimize kallsyms_lookup_name() for a few cases
@ 2017-04-25 16:18 Naveen N. Rao
  2017-04-25 16:36 ` David Laight
  2017-04-26 10:44 ` Michael Ellerman
  0 siblings, 2 replies; 7+ messages in thread
From: Naveen N. Rao @ 2017-04-25 16:18 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Masami Hiramatsu, Paul Clarke, David Laight, linux-kernel,
	linuxppc-dev

1. Fail early for invalid/zero length symbols.
2. Detect names of the form <mod:name> and skip checking for kernel
symbols in that case.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
Masami, Michael,
I have added two very simple checks here, which I felt is good to have,
rather than the elaborate checks in the previous version. Given the
change in module code to use strnchr(), the checks are now safe and
further tests are not probably not that useful.

- Naveen

 kernel/kallsyms.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 6a3b249a2ae1..d134b060564f 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -205,6 +205,12 @@ unsigned long kallsyms_lookup_name(const char *name)
 	unsigned long i;
 	unsigned int off;
 
+	if (!name || *name == '\0')
+		return false;
+
+	if (strnchr(name, MODULE_NAME_LEN, ':'))
+		return module_kallsyms_lookup_name(name);
+
 	for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
 		off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf));
 
-- 
2.12.1

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

end of thread, other threads:[~2017-06-27  9:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-25 16:18 [PATCH] kallsyms: optimize kallsyms_lookup_name() for a few cases Naveen N. Rao
2017-04-25 16:36 ` David Laight
2017-04-25 17:17   ` Naveen N. Rao
2017-04-26 10:44 ` Michael Ellerman
2017-04-26 20:08   ` Naveen N. Rao
2017-04-27  2:21     ` Masami Hiramatsu
2017-06-27  9:28       ` Naveen N. Rao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).