Skip to content

Commit cd6c956

Browse files
jonasjelonekAndi Shyti
authored andcommitted
i2c: rtl9300: fix channel number bound check
Fix the current check for number of channels (child nodes in the device tree). Before, this was: if (device_get_child_node_count(dev) >= RTL9300_I2C_MUX_NCHAN) RTL9300_I2C_MUX_NCHAN gives the maximum number of channels so checking with '>=' isn't correct because it doesn't allow the last channel number. Thus, fix it to: if (device_get_child_node_count(dev) > RTL9300_I2C_MUX_NCHAN) Issue occured on a TP-Link TL-ST1008F v2.0 device (8 SFP+ ports) and fix is tested there. Fixes: c366be7 ("i2c: Add driver for the RTL9300 I2C controller") Cc: [email protected] # v6.13+ Signed-off-by: Jonas Jelonek <[email protected]> Tested-by: Sven Eckelmann <[email protected]> Reviewed-by: Chris Packham <[email protected]> Tested-by: Chris Packham <[email protected]> # On RTL9302C based board Tested-by: Markus Stockhausen <[email protected]> Signed-off-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 664596b commit cd6c956

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/i2c/busses/i2c-rtl9300.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
353353

354354
platform_set_drvdata(pdev, i2c);
355355

356-
if (device_get_child_node_count(dev) >= RTL9300_I2C_MUX_NCHAN)
356+
if (device_get_child_node_count(dev) > RTL9300_I2C_MUX_NCHAN)
357357
return dev_err_probe(dev, -EINVAL, "Too many channels\n");
358358

359359
device_for_each_child_node(dev, child) {

0 commit comments

Comments
 (0)