Skip to content

Commit 248d3a7

Browse files
Junjie650dtor
authored andcommitted
Input: ti_am335x_tsc - fix off-by-one error in wire_order validation
The current validation 'wire_order[i] > ARRAY_SIZE(config_pins)' allows wire_order[i] to equal ARRAY_SIZE(config_pins), which causes out-of-bounds access when used as index in 'config_pins[wire_order[i]]'. Since config_pins has 4 elements (indices 0-3), the valid range for wire_order should be 0-3. Fix the off-by-one error by using >= instead of > in the validation check. Signed-off-by: Junjie Cao <junjie.cao@intel.com> Link: https://patch.msgid.link/20251114062817.852698-1-junjie.cao@intel.com Fixes: bb76dc0 ("input: ti_am33x_tsc: Order of TSC wires, made configurable") Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 806ec7b commit 248d3a7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/input/touchscreen/ti_am335x_tsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static int titsc_config_wires(struct titsc *ts_dev)
8585
wire_order[i] = ts_dev->config_inp[i] & 0x0F;
8686
if (WARN_ON(analog_line[i] > 7))
8787
return -EINVAL;
88-
if (WARN_ON(wire_order[i] > ARRAY_SIZE(config_pins)))
88+
if (WARN_ON(wire_order[i] >= ARRAY_SIZE(config_pins)))
8989
return -EINVAL;
9090
}
9191

0 commit comments

Comments
 (0)