kallsyms: fix segfault in prefix_underscores_count()
Paul Mundt authored
commit a9ece53c upstream.

Commit b478b782

 "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: default avatarPaul Mundt <lethal@linux-sh.org>
Reviewed-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Paulo Marques <pmarques@grupopie.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
43993370
Name Last commit Last update
..
basic Update .gitignore files for generated targets
dtc Move dtc and libfdt sources from arch/powerpc/boot to scripts/dtc
genksyms Revert "kbuild: strip generated symbols from *.ko"
kconfig kconfig: fix update-po-config to accect backslash in input
ksymoops Linux-2.6.12-rc2
mod kbuild, modpost: fix unexpected non-allocatable warning with mips
package parisc: fix "make tar-pkg"
rt-tester [PATCH] rtmutex: Modify rtmutex-tester to test the setscheduler propagation
selinux SELinux: add gitignore file for mdp script
tracing tracing: move scripts/trace/power.pl to scripts/tracing/power.pl
.gitignore Revert "fix modules_install via NFS"
Kbuild.include kbuild: use KECHO convenience echo
Lindent scripts/Lindent: support gnu indent v2.2.10
Makefile Move dtc and libfdt sources from arch/powerpc/boot to scripts/dtc
Makefile.build kbuild: introduce subdir-ccflags-y
Makefile.clean kbuild: fix some minor typoes
Makefile.fwinst firmware: silence __fw_modbuild and __fw_modinst 'Nothing to be done' messages
Makefile.headersinst kbuild: introduce destination-y for exported headers
Makefile.host kbuild: fix some minor typoes
Makefile.lib kbuild: introduce subdir-ccflags-y
Makefile.modinst Revert "kbuild: strip generated symbols from *.ko"
Makefile.modpost kbuild: fix KBUILD_EXTRA_SYMBOLS
bin2c.c Linux-2.6.12-rc2
bin_size bzip2/lzma: library support for gzip, bzip2 and lzma decompression
binoffset.c update the email address of Randy Dunlap
bloat-o-meter
bootgraph.pl
checkincludes.pl
checkkconfigsymbols.sh
checkpatch.pl
checkstack.pl
checksyscalls.sh
checkversion.pl
cleanfile
cleanpatch
config
conmakehash.c
decodecode
diffconfig
export_report.pl
extract-ikconfig
gcc-version.sh
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen_initramfs_list.sh
get_maintainer.pl
headerdep.pl
headers.sh
headers_check.pl
headers_install.pl
kallsyms.c
kernel-doc
makelst
markup_oops.pl
mkcompile_h
mkmakefile
mksysmap
mkuboot.sh
mkversion
namespace.pl
patch-kernel
pnmtologo.c
profile2linkerlist.pl
recordmcount.pl
setlocalversion
show_delta
tags.sh
unifdef.c
ver_linux