Skip to content

Commit

Permalink
script/sorttable: Fix some initialization problems
Browse files Browse the repository at this point in the history
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/[email protected]
Link: https://lkml.kernel.org/r/[email protected]

Fixes: 72b3942 ("scripts: ftrace - move the sort-processing in ftrace_init")
Tested-by: Nathan Chancellor <[email protected]>
Reviewed-by: Nathan Chancellor <[email protected]>
Signed-off-by: Yinan Liu <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
Yinan Liu authored and rostedt committed Jan 18, 2022
1 parent f37c3bb commit 35140d3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/sorttable.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ static int compare_extable(const void *a, const void *b)
return 0;
}
#ifdef MCOUNT_SORT_ENABLED
pthread_t mcount_sort_thread;

struct elf_mcount_loc {
Elf_Ehdr *ehdr;
Elf_Shdr *init_data_sec;
Expand Down Expand Up @@ -282,10 +284,9 @@ static int do_sort(Elf_Ehdr *ehdr,
unsigned int shnum;
unsigned int shstrndx;
#ifdef MCOUNT_SORT_ENABLED
struct elf_mcount_loc mstruct;
struct elf_mcount_loc mstruct = {0};
uint_t _start_mcount_loc = 0;
uint_t _stop_mcount_loc = 0;
pthread_t mcount_sort_thread;
#endif
#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)
unsigned int orc_ip_size = 0;
Expand Down

0 comments on commit 35140d3

Please sign in to comment.