Skip to content

Commit

Permalink
kallsyms: fix segfault in prefix_underscores_count()
Browse files Browse the repository at this point in the history
Commit b478b78 "kallsyms, tracing: output
more proper symbol name" introduces a "bugfix" that introduces a segfault
in kallsyms in my configurations.

The cause is the introduction of prefix_underscores_count() which attempts
to count underscores, even in symbols that do not have them.  As a result,
it just uselessly runs past the end of the buffer until it crashes:

  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
  KSYM    .tmp_kallsyms1.S
/bin/sh: line 1: 16934 Done                    sh-linux-gnu-nm -n .tmp_vmlinux1
     16935 Segmentation fault      | scripts/kallsyms > .tmp_kallsyms1.S
make: *** [.tmp_kallsyms1.S] Error 139

This simplifies the logic and just does a straightforward count.

Signed-off-by: Paul Mundt <[email protected]>
Reviewed-by: Li Zefan <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Cc: Sam Ravnborg <[email protected]>
Cc: Paulo Marques <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]>		[2.6.30.x, 2.6.31.x]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
pmundt authored and torvalds committed Sep 23, 2009
1 parent 1f10206 commit a9ece53
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ static int prefix_underscores_count(const char *str)
{
const char *tail = str;

while (*tail != '_')
while (*tail == '_')
tail++;

return tail - str;
Expand Down

0 comments on commit a9ece53

Please sign in to comment.