diff options
| author | Markus Elfring <Markus.Elfring@web.de> | 2023-04-13 14:46:39 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-05-17 11:11:49 +0200 |
| commit | a706ae51b503f87ea74394b9b1494d57f81cf2eb (patch) | |
| tree | 1dbb3e316160ec2a19ef7515ce60e9c586cb2816 | |
| parent | e2fd41a23a08e9e12adbfeef595d1354b954ef11 (diff) | |
| download | linux-a706ae51b503f87ea74394b9b1494d57f81cf2eb.tar.gz linux-a706ae51b503f87ea74394b9b1494d57f81cf2eb.tar.bz2 linux-a706ae51b503f87ea74394b9b1494d57f81cf2eb.zip | |
perf map: Delete two variable initialisations before null pointer checks in sort__sym_from_cmp()
[ Upstream commit c160118a90d4acf335993d8d59b02ae2147a524e ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | tools/perf/util/sort.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index cd870129131e..4fe2f3f92ab1 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -753,8 +753,7 @@ static int hist_entry__dso_to_filter(struct hist_entry *he, int type, static int64_t sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right) { - struct addr_map_symbol *from_l = &left->branch_info->from; - struct addr_map_symbol *from_r = &right->branch_info->from; + struct addr_map_symbol *from_l, *from_r; if (!left->branch_info || !right->branch_info) return cmp_null(left->branch_info, right->branch_info); |
