mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] misc: ti_fpc202: fix port ID bounds check
@ 2026-03-22  3:19 Pengpeng Hou
  2026-03-23  8:25 ` Romain Gantois
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-03-22  3:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: pengpeng, Romain Gantois, Arnd Bergmann, Greg Kroah-Hartman

The probe path accepts `port_id == FPC202_NUM_PORTS` even though the
driver stores per-port state in `addr_caches[2][2]` and
`probed_ports` is indexed by the same range. That lets a device-tree
node with `reg = <2>` flow into `fpc202_write_dev_addr()` and
`fpc202_detach_addr()`, where the driver indexes
`addr_caches[port_id][dev_num]`.

Change the probe check to reject port ID values at or above the number
of supported ports.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/misc/ti_fpc202.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ti_fpc202.c b/drivers/misc/ti_fpc202.c
index 8eb2b5ac9850..578feefb77f1 100644
--- a/drivers/misc/ti_fpc202.c
+++ b/drivers/misc/ti_fpc202.c
@@ -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;
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-23  8:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-22  3:19 [PATCH] misc: ti_fpc202: fix port ID bounds check Pengpeng Hou
2026-03-23  8:25 ` Romain Gantois

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®