diff options
| author | Old-Ding <[email protected]> | 2026-07-06 06:14:04 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2026-07-08 14:02:15 +0800 |
| commit | d2d89271ea794cb8d7fd900eb7246053ec7a7b94 (patch) | |
| tree | 71de5b359309803ec3041729fe390a101e5f60a0 /components | |
| parent | 1648becff87b951afe6eb441793d087c9a38e4b5 (diff) | |
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 <[email protected]>
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/regulator/regulator-fan53555.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/components/drivers/regulator/regulator-fan53555.c b/components/drivers/regulator/regulator-fan53555.c index 3d5e58eb54..f7b68a958f 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"); |
