Skip to content

Commit 2692752

Browse files
captain5050gregkh
authored andcommitted
perf disasm: Avoid undefined behavior in incrementing NULL
[ Upstream commit 78d8535 ] Incrementing NULL is undefined behavior and triggers ubsan during the perf annotate test. Split a compound statement over two lines to avoid this. Fixes: 98f69a5 ("perf annotate: Split out util/disasm.c") Reviewed-by: Collin Funk <collin.funk1@gmail.com> Reviewed-by: James Clark <james.clark@linaro.org> Reviewed-by: Kuan-Wei Chiu <visitorckw@gmail.com> Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Blake Jones <blakejones@google.com> Cc: Chun-Tse Shao <ctshao@google.com> Cc: Howard Chu <howardchu95@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jan Polensky <japo@linux.ibm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Li Huafei <lihuafei1@huawei.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Nam Cao <namcao@linutronix.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20250821163820.1132977-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1aeb7e6 commit 2692752

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/perf/util/disasm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,16 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s
389389
* skip over possible up to 2 operands to get to address, e.g.:
390390
* tbnz w0, #26, ffff0000083cd190 <security_file_permission+0xd0>
391391
*/
392-
if (c++ != NULL) {
392+
if (c != NULL) {
393+
c++;
393394
ops->target.addr = strtoull(c, NULL, 16);
394395
if (!ops->target.addr) {
395396
c = strchr(c, ',');
396397
c = validate_comma(c, ops);
397-
if (c++ != NULL)
398+
if (c != NULL) {
399+
c++;
398400
ops->target.addr = strtoull(c, NULL, 16);
401+
}
399402
}
400403
} else {
401404
ops->target.addr = strtoull(ops->raw, NULL, 16);

0 commit comments

Comments
 (0)