Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf map: Delete two variable initialisations before null pointer checks in sort__sym_from_cmp()

Addresses of two data structure members were determined before
corresponding null pointer checks in the implementation of the function
“sort__sym_from_cmp”.

Thus avoid the risk for undefined behaviour by removing extra
initialisations for the local variables “from_l” and “from_r” (also
because they were already reassigned with the same value behind this
pointer check).

This issue was detected by using the Coccinelle software.

Fixes: 1b9e97a2a95e4941 ("perf tools: Fix report -F symbol_from for data without branch info")
Signed-off-by: <elfring@users.sourceforge.net>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/cocci/54a21fea-64e3-de67-82ef-d61b90ffad05@web.de/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Markus Elfring and committed by
Arnaldo Carvalho de Melo
c160118a ee31f6fe

+1 -2
+1 -2
tools/perf/util/sort.c
··· 1020 1020 static int64_t 1021 1021 sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right) 1022 1022 { 1023 - struct addr_map_symbol *from_l = &left->branch_info->from; 1024 - struct addr_map_symbol *from_r = &right->branch_info->from; 1023 + struct addr_map_symbol *from_l, *from_r; 1025 1024 1026 1025 if (!left->branch_info || !right->branch_info) 1027 1026 return cmp_null(left->branch_info, right->branch_info);