Skip to content

Commit 3f43926

Browse files
tititiou36alexandrebelloni
authored andcommitted
i3c/master/mipi-i3c-hci: Fix a potentially infinite loop in 'hci_dat_v1_get_index()'
The code in 'hci_dat_v1_get_index()' really looks like a hand coded version of 'for_each_set_bit()', except that a +1 is missing when searching for the next set bit. This really looks odd and it seems that it will loop until 'dat_w0_read()' returns the expected result. So use 'for_each_set_bit()' instead. It is less verbose and should be more correct. Fixes: 9ad9a52 ("i3c/master: introduce the mipi-i3c-hci driver") Signed-off-by: Christophe JAILLET <[email protected]> Acked-by: Nicolas Pitre <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/0cdf3cb10293ead1acd271fdb8a70369c298c082.1637186628.git.christophe.jaillet@wanadoo.fr
1 parent f18f981 commit 3f43926

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/i3c/master/mipi-i3c-hci/dat_v1.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ static int hci_dat_v1_get_index(struct i3c_hci *hci, u8 dev_addr)
160160
unsigned int dat_idx;
161161
u32 dat_w0;
162162

163-
for (dat_idx = find_first_bit(hci->DAT_data, hci->DAT_entries);
164-
dat_idx < hci->DAT_entries;
165-
dat_idx = find_next_bit(hci->DAT_data, hci->DAT_entries, dat_idx)) {
163+
for_each_set_bit(dat_idx, hci->DAT_data, hci->DAT_entries) {
166164
dat_w0 = dat_w0_read(dat_idx);
167165
if (FIELD_GET(DAT_0_DYNAMIC_ADDRESS, dat_w0) == dev_addr)
168166
return dat_idx;

0 commit comments

Comments
 (0)