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

perf symbol: Avoid an undefined behavior warning

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>
Cc: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20230914044233.1550195-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
21ce931e 999b81b9

+1 -2
+1 -2
tools/perf/util/symbol.c
··· 202 202 curr = rb_entry(nd, struct symbol, rb_node); 203 203 again: 204 204 nd = rb_next(&curr->rb_node); 205 - next = rb_entry(nd, struct symbol, rb_node); 206 - 207 205 if (!nd) 208 206 break; 209 207 208 + next = rb_entry(nd, struct symbol, rb_node); 210 209 if (curr->start != next->start) 211 210 continue; 212 211