[lvc-project] [PATCH 5.10 1/2] Input: adp5588-keys - Add check on return code
Denis Arefev
arefev at swemel.ru
Wed May 21 13:40:23 MSK 2025
Function 'adp5588_read()' can return a negative value, which after
calculations will be used as an index to access the array
'kpad->keycode'.
Add a check for the return value.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 69a4af606ed4 ("Input: adp5588-keys - support GPI events for ADP5588 devices")
Signed-off-by: Denis Arefev <arefev at swemel.ru>
---
drivers/input/keyboard/adp5588-keys.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 90a59b973d00..60099a6a4bf9 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -269,8 +269,14 @@ static void adp5588_report_events(struct adp5588_kpad *kpad, int ev_cnt)
int i, j;
for (i = 0; i < ev_cnt; i++) {
- int key = adp5588_read(kpad->client, Key_EVENTA + i);
- int key_val = key & KEY_EV_MASK;
+ int key, key_val, key_press;
+
+ key = adp5588_read(kpad->client, Key_EVENTA + i);
+ if (key < 0)
+ continue;
+
+ key_val = key & KEY_EV_MASK;
+ key_press = key & KEY_EV_PRESSED;
if (key_val >= GPI_PIN_BASE && key_val <= GPI_PIN_END) {
for (j = 0; j < kpad->gpimapsize; j++) {
--
2.43.0
More information about the lvc-project
mailing list