This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit dd7d211f7bc1473161ae950227b15956ad1c9701 Author: yushuailong <[email protected]> AuthorDate: Sat Sep 26 11:14:45 2026 +0800 sched/profil: Bound samples to complete counters. Round the usable profiling buffer size down to complete unsigned short counters before deriving highpc. Without this, an odd-sized buffer can allow the timer handler to increment a counter that extends one byte past the buffer. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <[email protected]> --- sched/sched/sched_profil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sched/sched/sched_profil.c b/sched/sched/sched_profil.c index cdd77a875a4..30de0a5f57a 100644 --- a/sched/sched/sched_profil.c +++ b/sched/sched/sched_profil.c @@ -149,7 +149,7 @@ int profil(FAR unsigned short *buf, size_t bufsiz, if (buf != NULL && scale != 0) { memset(buf, 0, bufsiz); - highpc = (uintmax_t)bufsiz * 65536 / scale; + highpc = (uintmax_t)(bufsiz & ~1) * 65536 / scale; flags = spin_lock_irqsave(&prof->lock); prof->counter = buf;
