Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 966c8c12 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds
Browse files

sprint_symbol(): use less stack



sprint_symbol(), itself used when dumping stacks, has been wasting 128
bytes of stack: lookup the symbol directly into the buffer supplied by the
caller, instead of using a locally declared namebuf.

I believe the name != buffer strcpy() is obsolete: the design here dates
from when module symbol lookup pointed into a supposedly const but sadly
volatile table; nowadays it copies, but an uncalled strcpy() looks better
here than the risk of a recursive BUG_ON().

Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3fa59dfb
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -304,17 +304,24 @@ int sprint_symbol(char *buffer, unsigned long address)
	char *modname;
	char *modname;
	const char *name;
	const char *name;
	unsigned long offset, size;
	unsigned long offset, size;
	char namebuf[KSYM_NAME_LEN];
	int len;


	name = kallsyms_lookup(address, &size, &offset, &modname, namebuf);
	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
	if (!name)
	if (!name)
		return sprintf(buffer, "0x%lx", address);
		return sprintf(buffer, "0x%lx", address);


	if (name != buffer)
		strcpy(buffer, name);
	len = strlen(buffer);
	buffer += len;

	if (modname)
	if (modname)
		return sprintf(buffer, "%s+%#lx/%#lx [%s]", name, offset,
		len += sprintf(buffer, "+%#lx/%#lx [%s]",
				size, modname);
						offset, size, modname);
	else
	else
		return sprintf(buffer, "%s+%#lx/%#lx", name, offset, size);
		len += sprintf(buffer, "+%#lx/%#lx", offset, size);

	return len;
}
}


/* Look up a kernel symbol and print it to the kernel messages. */
/* Look up a kernel symbol and print it to the kernel messages. */