summaryrefslogtreecommitdiff
path: root/common/led_pwm.c
diff options
context:
space:
mode:
authorJonathan Brandmeyer <jbrandmeyer@chromium.org>2018-07-19 16:37:14 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-07-20 15:10:15 -0700
commit3fe8066ca9d4b50c04ba7d338b3feb4ebba5233b (patch)
tree63bbfa5f60513e2162641d386e3de9e5da17431f /common/led_pwm.c
parentb6bb2782ddd3f26c6ec2cc781758c76fb434a282 (diff)
downloadchrome-ec-3fe8066ca9d4b50c04ba7d338b3feb4ebba5233b.tar.gz
cleanup: Resolve some defects seen with Coverity.
- Correct two range checks in set_pwm_led_color(). The erroneous checks allowed a real array out-of-bounds error accessible via the EC console. Scope is limited to pre-release hardware that had enabled CONFIG_CMD_LEDTEST. - Correct comparisons of unsigned integers to a negative constant. - Add an explicit /* fallthrough */ on an un-recognized deliberate fallthrough. TEST=make -j buildall BUG=none BRANCH=none Change-Id: Ifc460427729ce597e945142f0256a1364b0a083e Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1145051 Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'common/led_pwm.c')
-rw-r--r--common/led_pwm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/led_pwm.c b/common/led_pwm.c
index 17201fb03e..3faa92cafe 100644
--- a/common/led_pwm.c
+++ b/common/led_pwm.c
@@ -56,8 +56,8 @@ void set_pwm_led_color(enum pwm_led_id id, int color)
{
struct pwm_led duty = { 0 };
- if ((id > CONFIG_LED_PWM_COUNT) || (id < 0) ||
- (color > EC_LED_COLOR_COUNT) || (color < -1))
+ if ((id >= CONFIG_LED_PWM_COUNT) || (id < 0) ||
+ (color >= EC_LED_COLOR_COUNT) || (color < -1))
return;
if (color != -1) {