Skip to content

Commit 6cbf8b3

Browse files
jamieilesalexandrebelloni
authored andcommitted
i3c: fix uninitialized variable use in i2c setup
Commit 31b9887 ("i3c: remove i2c board info from i2c_dev_desc") removed the boardinfo from i2c_dev_desc to decouple device enumeration from setup but did not correctly lookup the i2c_dev_desc to store the new device, instead dereferencing an uninitialized variable. Lookup the device that has already been registered by address to store the i2c client device. Fixes: 31b9887 ("i3c: remove i2c board info from i2c_dev_desc") Reported-by: kernel test robot <lkp@intel.com> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Jamie Iles <quic_jiles@quicinc.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220308134226.1042367-1-quic_jiles@quicinc.com
1 parent 72a4501 commit 6cbf8b3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/i3c/master.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,8 +2307,13 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
23072307
* We silently ignore failures here. The bus should keep working
23082308
* correctly even if one or more i2c devices are not registered.
23092309
*/
2310-
list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node)
2310+
list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node) {
2311+
i2cdev = i3c_master_find_i2c_dev_by_addr(master,
2312+
i2cboardinfo->base.addr);
2313+
if (WARN_ON(!i2cdev))
2314+
continue;
23112315
i2cdev->dev = i2c_new_client_device(adap, &i2cboardinfo->base);
2316+
}
23122317

23132318
return 0;
23142319
}

0 commit comments

Comments
 (0)