public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf dwarf-regs: Fix off by one in __get_dwarf_regnum_for_perf_regnum_csky()
@ 2026-04-23  7:00 Dan Carpenter
  2026-04-23  9:13 ` James Clark
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2026-04-23  7:00 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, James Clark, Guo Ren, linux-perf-users,
	linux-kernel, linux-csky, kernel-janitors

Change the > comparison >= to prevent an out of bounds access of
the dwarf_csky_regnumsp[] array.

Fixes: 8cac4013b0c2 ("perf dwarf-regs: Add csky perf to dwarf register number mapping functions")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
---
 tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
index cb44b774f8d9..4c586a5cb763 100644
--- a/tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
+++ b/tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
@@ -118,7 +118,7 @@ int __get_dwarf_regnum_for_perf_regnum_csky(int perf_regnum, unsigned int flags)
 	if (flags & EF_CSKY_ABIV2)
 		idx++;
 
-	if (perf_regnum <  0 || perf_regnum > (int)ARRAY_SIZE(dwarf_csky_regnums) ||
+	if (perf_regnum <  0 || perf_regnum >= (int)ARRAY_SIZE(dwarf_csky_regnums) ||
 	    dwarf_csky_regnums[perf_regnum][idx] == 0)
 		return -ENOENT;
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-23  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23  7:00 [PATCH] perf dwarf-regs: Fix off by one in __get_dwarf_regnum_for_perf_regnum_csky() Dan Carpenter
2026-04-23  9:13 ` James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox