Skip to content

Commit 35140d3

Browse files
Yinan Liurostedt
authored andcommitted
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: 72b3942 ("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>
1 parent f37c3bb commit 35140d3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/sorttable.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ static int compare_extable(const void *a, const void *b)
199199
return 0;
200200
}
201201
#ifdef MCOUNT_SORT_ENABLED
202+
pthread_t mcount_sort_thread;
203+
202204
struct elf_mcount_loc {
203205
Elf_Ehdr *ehdr;
204206
Elf_Shdr *init_data_sec;
@@ -282,10 +284,9 @@ static int do_sort(Elf_Ehdr *ehdr,
282284
unsigned int shnum;
283285
unsigned int shstrndx;
284286
#ifdef MCOUNT_SORT_ENABLED
285-
struct elf_mcount_loc mstruct;
287+
struct elf_mcount_loc mstruct = {0};
286288
uint_t _start_mcount_loc = 0;
287289
uint_t _stop_mcount_loc = 0;
288-
pthread_t mcount_sort_thread;
289290
#endif
290291
#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)
291292
unsigned int orc_ip_size = 0;

0 commit comments

Comments
 (0)