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>
This commit is contained in:
Jilay Pandya 2024-12-19 23:03:56 +01:00 committed by Benjamin Cabé
parent b56aa0e823
commit 3202773b11

View file

@ -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;
} }