From 17bced75f710389f6d538526041b4a1f63a1647c Mon Sep 17 00:00:00 2001 From: Old-Ding <35417409+Old-Ding@users.noreply.github.com> Date: Mon, 6 Jul 2026 06:14:04 +0800 Subject: [PATCH] drivers: fix fan53555 slew rate bounds check Valid slew_rates indices are 0 through RT_ARRAY_SIZE(slew_rates) - 1. The current check rejects only values greater than the table size, allowing slew_idx == RT_ARRAY_SIZE(slew_rates) to index one element past the table. Generated-by: OpenAI Codex Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com> --- components/drivers/regulator/regulator-fan53555.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/drivers/regulator/regulator-fan53555.c b/components/drivers/regulator/regulator-fan53555.c index 3d5e58eb54a..f7b68a958f8 100644 --- a/components/drivers/regulator/regulator-fan53555.c +++ b/components/drivers/regulator/regulator-fan53555.c @@ -550,7 +550,7 @@ static rt_err_t fan53555_regulator_probe(struct rt_i2c_client *client) { int slew_idx = freg->slew_rate; - if (slew_idx > RT_ARRAY_SIZE(slew_rates)) + if (slew_idx >= RT_ARRAY_SIZE(slew_rates)) { LOG_E("Invalid slew rate");