drivers: pic: fix PIRQ lookup upper bound#11573
Conversation
rt_pic_linear_irq() stores irq_nr as a count and assigns pic->pirqs to the first entry in that range. rt_pic_find_pirq() therefore must treat the upper bound as exclusive. The inclusive check could return pic->pirqs[irq_nr] when irq equals irq_start + irq_nr, which is one entry past the allocated range. Generated-by: OpenAI Codex Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-07-06 11:08 CST)
📝 Review Instructions
|
What this PR does
Fixes the upper-bound check in
rt_pic_find_pirq().rt_pic_linear_irq()storesirq_nras a count and setspic->pirqsto the first entry in that range. The valid IRQ range is therefore[irq_start, irq_start + irq_nr). The current inclusive check can returnpic->pirqs[irq_nr]whenirq == irq_start + irq_nr, which is one entry past the range.Verification
git diff --checkgit show --stat --check --format=fuller HEADgit ls-files --eol -- components/drivers/pic/pic.cI could not run an RT-Thread build locally because this Windows environment does not have
scons,gcc, orarm-none-eabi-gccinstalled.Generated-by: OpenAI Codex