cs_etm__frontend_mem_access() can return zero or a short read without fully initializing instrBytes. cs_etm__t32_instr_size() nevertheless inspects its second byte. With CORESIGHT=1 and -O3, GCC 15.2.0 reports:
error: 'instrBytes' may be used uninitialized
Zero-initialize the buffer to avoid reading uninitialized stack data when instruction memory is unavailable and fix the build failure.
Reported-by: Ian Rogers irogers@google.com Closes: https://lore.kernel.org/linux-perf-users/20261030-perf_cs_etm_fix_non_taken-... Fixes: a7ee4d625ede ("perf cs-etm: Support for ARM A32/T32 instruction sets in CoreSight trace") Signed-off-by: Leo Yan leo.yan@arm.com --- tools/perf/util/cs-etm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 3e01b401ca6f3a08f44bb69204317efaf2fa18d0..25f12bd110934a204d79244f45317085b7a81666 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1369,7 +1369,7 @@ static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq, struct cs_etm_packet *packet, u64 addr) { - u8 instrBytes[2]; + u8 instrBytes[2] = { 0 };
cs_etm__frontend_mem_access(etmq, tidq, packet, addr, ARRAY_SIZE(instrBytes), instrBytes);