Skip to content

Commit 35163f6

Browse files
nxpfrankligregkh
authored andcommitted
i3c: master: svc: fix possible assignment of the same address to two devices
commit 3b2ac81 upstream. svc_i3c_master_do_daa() { ... for (i = 0; i < dev_nb; i++) { ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); if (ret) goto rpm_out; } } If two devices (A and B) are detected in DAA and address 0xa is assigned to device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() for device A (addr: 0xa) could prevent device B (addr: 0xb) from being registered on the bus. The I3C stack might still consider 0xb a free address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, causing both devices A and B to use the same address 0xb, violating the I3C specification. The return value for i3c_master_add_i3c_dev_locked() should not be checked because subsequent steps will scan the entire I3C bus, independent of whether i3c_master_add_i3c_dev_locked() returns success. If device A registration fails, there is still a chance to register device B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while retrieving device information. Cc: [email protected] Fixes: 317bacf ("i3c: master: add enable(disable) hot join in sys entry") Reviewed-by: Miquel Raynal <[email protected]> Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 43bbc5f commit 35163f6

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

drivers/i3c/master/svc-i3c-master.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,27 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)
10181018
goto rpm_out;
10191019
}
10201020

1021-
/* Register all devices who participated to the core */
1022-
for (i = 0; i < dev_nb; i++) {
1023-
ret = i3c_master_add_i3c_dev_locked(m, addrs[i]);
1024-
if (ret)
1025-
goto rpm_out;
1026-
}
1021+
/*
1022+
* Register all devices who participated to the core
1023+
*
1024+
* If two devices (A and B) are detected in DAA and address 0xa is assigned to
1025+
* device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked()
1026+
* for device A (addr: 0xa) could prevent device B (addr: 0xb) from being
1027+
* registered on the bus. The I3C stack might still consider 0xb a free
1028+
* address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A,
1029+
* causing both devices A and B to use the same address 0xb, violating the I3C
1030+
* specification.
1031+
*
1032+
* The return value for i3c_master_add_i3c_dev_locked() should not be checked
1033+
* because subsequent steps will scan the entire I3C bus, independent of
1034+
* whether i3c_master_add_i3c_dev_locked() returns success.
1035+
*
1036+
* If device A registration fails, there is still a chance to register device
1037+
* B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while
1038+
* retrieving device information.
1039+
*/
1040+
for (i = 0; i < dev_nb; i++)
1041+
i3c_master_add_i3c_dev_locked(m, addrs[i]);
10271042

10281043
/* Configure IBI auto-rules */
10291044
ret = svc_i3c_update_ibirules(master);

0 commit comments

Comments
 (0)