* [PATCH v1] perf symbol: Avoid an undefined behavior warning
@ 2023-09-14 4:42 Ian Rogers
2023-09-17 5:29 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2023-09-14 4:42 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter, James Clark, linux-perf-users,
linux-kernel
The node (nd) may be NULL and pointer arithmetic on NULL is undefined
behavior. Move the computation of next below the NULL check on the
node.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/symbol.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 3f36675b7c8f..5b54d2639df4 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -202,11 +202,10 @@ void symbols__fixup_duplicate(struct rb_root_cached *symbols)
curr = rb_entry(nd, struct symbol, rb_node);
again:
nd = rb_next(&curr->rb_node);
- next = rb_entry(nd, struct symbol, rb_node);
-
if (!nd)
break;
+ next = rb_entry(nd, struct symbol, rb_node);
if (curr->start != next->start)
continue;
--
2.42.0.459.ge4e396fd5e-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] perf symbol: Avoid an undefined behavior warning
2023-09-14 4:42 [PATCH v1] perf symbol: Avoid an undefined behavior warning Ian Rogers
@ 2023-09-17 5:29 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2023-09-17 5:29 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
James Clark, linux-perf-users, linux-kernel
On Wed, Sep 13, 2023 at 9:42 PM Ian Rogers <irogers@google.com> wrote:
>
> The node (nd) may be NULL and pointer arithmetic on NULL is undefined
> behavior. Move the computation of next below the NULL check on the
> node.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Applied to perf-tools-next, thanks!
Namhyung
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-17 5:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14 4:42 [PATCH v1] perf symbol: Avoid an undefined behavior warning Ian Rogers
2023-09-17 5:29 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).