]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
misc: ti_fpc202: fix off-by-one error in port ID bounds check
authorFelix Gu <ustc.gu@gmail.com>
Fri, 20 Feb 2026 17:20:31 +0000 (01:20 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2026 14:29:19 +0000 (16:29 +0200)
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: 1e5c9b1efa1c ("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>
drivers/misc/ti_fpc202.c

index 8eb2b5ac9850627dc97aefb62cee5e75cc0fdc9a..578feefb77f1e2edbe3133254d7b9b3e761c07b3 100644 (file)
@@ -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;