script/sorttable: Fix some initialization problems

elf_mcount_loc and mcount_sort_thread definitions are not
initialized immediately within the function, which can cause
the judgment logic to use uninitialized values when the
initialization logic of subsequent code fails.

Link: https://lkml.kernel.org/r/20211212113358.34208-2-yinan@linux.alibaba.com
Link: https://lkml.kernel.org/r/20220118065241.42364-1-yinan@linux.alibaba.com

Fixes: 72b3942a17 ("scripts: ftrace - move the sort-processing in ftrace_init")
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Yinan Liu <yinan@linux.alibaba.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Yinan Liu 2022-01-18 14:52:41 +08:00 committed by Steven Rostedt
parent f37c3bbc63
commit 35140d399d
1 changed files with 3 additions and 2 deletions

View File

@ -199,6 +199,8 @@ static int compare_extable(const void *a, const void *b)
return 0; return 0;
} }
#ifdef MCOUNT_SORT_ENABLED #ifdef MCOUNT_SORT_ENABLED
pthread_t mcount_sort_thread;
struct elf_mcount_loc { struct elf_mcount_loc {
Elf_Ehdr *ehdr; Elf_Ehdr *ehdr;
Elf_Shdr *init_data_sec; Elf_Shdr *init_data_sec;
@ -282,10 +284,9 @@ static int do_sort(Elf_Ehdr *ehdr,
unsigned int shnum; unsigned int shnum;
unsigned int shstrndx; unsigned int shstrndx;
#ifdef MCOUNT_SORT_ENABLED #ifdef MCOUNT_SORT_ENABLED
struct elf_mcount_loc mstruct; struct elf_mcount_loc mstruct = {0};
uint_t _start_mcount_loc = 0; uint_t _start_mcount_loc = 0;
uint_t _stop_mcount_loc = 0; uint_t _stop_mcount_loc = 0;
pthread_t mcount_sort_thread;
#endif #endif
#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED) #if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)
unsigned int orc_ip_size = 0; unsigned int orc_ip_size = 0;