diff options
author | Jonathan Brandmeyer <jbrandmeyer@chromium.org> | 2018-07-19 16:37:14 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-20 15:10:15 -0700 |
commit | 3fe8066ca9d4b50c04ba7d338b3feb4ebba5233b (patch) | |
tree | 63bbfa5f60513e2162641d386e3de9e5da17431f /common/spi_flash_reg.c | |
parent | b6bb2782ddd3f26c6ec2cc781758c76fb434a282 (diff) | |
download | chrome-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/spi_flash_reg.c')
-rw-r--r-- | common/spi_flash_reg.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/spi_flash_reg.c b/common/spi_flash_reg.c index 1301e19dc5..569bbd5072 100644 --- a/common/spi_flash_reg.c +++ b/common/spi_flash_reg.c @@ -111,7 +111,7 @@ int spi_flash_reg_to_protect(uint8_t sr1, uint8_t sr2, unsigned int *start, >> 2; /* Bad pointers or invalid data */ - if (!start || !len || sr1 == -1 || sr2 == -1) + if (!start || !len || sr1 == 0xff || sr2 == 0xff) return EC_ERROR_INVAL; for (i = 0; i < ARRAY_SIZE(spi_flash_protect_ranges); ++i) { @@ -159,7 +159,7 @@ int spi_flash_protect_to_reg(unsigned int start, unsigned int len, uint8_t *sr1, char bp = 0; /* Bad pointers */ - if (!sr1 || !sr2 || *sr1 == -1 || *sr2 == -1) + if (!sr1 || !sr2) return EC_ERROR_INVAL; /* Invalid data */ |