Skip to content

Commit a08c1f1

Browse files
nxpfrankligregkh
authored andcommitted
i3c: master: svc: fix possible assignment of the same address to two devices
commit 3b2ac810d86eb96e882db80a3320a3848b133208 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: 317bacf960a4 ("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 e9645cf commit a08c1f1

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
@@ -1010,12 +1010,27 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)
10101010
goto rpm_out;
10111011
}
10121012

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

10201035
/* Configure IBI auto-rules */
10211036
ret = svc_i3c_update_ibirules(master);

0 commit comments

Comments
 (0)