Browse Source

drivers: auxdisplay: jhd1313: fix Out-of-bounds read

fix out of bounds read by doing the comparison with ARRAY_SIZE correctly

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
(cherry picked from commit 3202773b11)
pull/84011/head
Jilay Pandya 7 months ago committed by Anas Nashif
parent
commit
d790dcc0f8
  1. 2
      drivers/auxdisplay/auxdisplay_jhd1313.c

2
drivers/auxdisplay/auxdisplay_jhd1313.c

@ -205,7 +205,7 @@ static int auxdisplay_jhd1313_backlight_set(const struct device *dev, uint8_t co
const struct auxdisplay_jhd1313_config *config = dev->config; const struct auxdisplay_jhd1313_config *config = dev->config;
struct auxdisplay_jhd1313_data *data = dev->data; struct auxdisplay_jhd1313_data *data = dev->data;
if (colour > ARRAY_SIZE(colour_define)) { if (colour >= ARRAY_SIZE(colour_define)) {
LOG_WRN("Selected colour is too high a value"); LOG_WRN("Selected colour is too high a value");
return -EINVAL; return -EINVAL;
} }

Loading…
Cancel
Save