mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 06:41:39 -04:00
misc: ti_fpc202: fix off-by-one error in port ID bounds check
FPC202_NUM_PORTS is 2, valid port IDs should be 0 and 1. A port_id of 2
would incorrectly pass the check, potentially causing out-of-bounds
access to the port-related arrays.
Found by code review, compile pass.
Fixes: 1e5c9b1efa ("misc: add FPC202 dual port controller driver")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20260221-fp202-v1-1-4d28cb8b28fb@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
eef2a8ddfa
commit
84664e43ef
@@ -366,7 +366,7 @@ static int fpc202_probe(struct i2c_client *client)
|
||||
goto unregister_chans;
|
||||
}
|
||||
|
||||
if (port_id > FPC202_NUM_PORTS) {
|
||||
if (port_id >= FPC202_NUM_PORTS) {
|
||||
dev_err(dev, "port ID %d is out of range!\n", port_id);
|
||||
ret = -EINVAL;
|
||||
goto unregister_chans;
|
||||
|
||||
Reference in New Issue
Block a user