From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> # pahole Segmentation fault (core dumped) # Now we have: # ls -la bla ls: cannot access 'bla': No such file or directory # export PAHOLE_VMLINUX_BTF_FILENAME=bla # pahole pahole: couldn't find any debug information on this system. # pahole list_head pahole: couldn't find any debug information on this system. # pahole -F btf list_head pahole: couldn't find any btf debug information on this system. # pahole -F dwarf list_head pahole: couldn't find any dwarf debug information on this system. # tests/default_vmlinux_btf.sh Default BTF on a system without BTF: Ok # Reported-by: Matthias Schwarzott <zzam@xxxxxxxxxx> Cc: Alan Maguire <alan.maguire@xxxxxxxxxx> Cc: Andrii Nakryiko <andrii@xxxxxxxxxx> Cc: Eduard Zingerman <eddyz87@xxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: Song Liu <song@xxxxxxxxxx> Cc: Yonghong Song <yonghong.song@xxxxxxxxx> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> --- dwarves.c | 3 +++ libctf.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dwarves.c b/dwarves.c index 459311e64c8b45b2..ae512b9f46ddcc0a 100644 --- a/dwarves.c +++ b/dwarves.c @@ -777,6 +777,9 @@ struct cu *cu__new(const char *name, uint8_t addr_size, if (cu->use_obstack) obstack_init(&cu->obstack); + if (name == NULL || filename == NULL) + goto out_free; + cu->name = strdup(name); if (cu->name == NULL) goto out_free; diff --git a/libctf.c b/libctf.c index edb34dbf10de09e7..0641b10586527a6e 100644 --- a/libctf.c +++ b/libctf.c @@ -179,6 +179,9 @@ struct ctf *ctf__new(const char *filename, Elf *elf) struct ctf *ctf = zalloc(sizeof(*ctf)); if (ctf != NULL) { + if (filename == NULL) + goto out_delete; + ctf->filename = strdup(filename); if (ctf->filename == NULL) goto out_delete; -- 2.47.0