Skip to content

Commit d6cb667

Browse files
stanleychuysalexandrebelloni
authored andcommitted
i3c: master: svc: Fix i3c_master_get_free_addr return check
The return value of i3c_master_get_free_addr is assigned to a variable with wrong type, so it can't be negative. Use a signed integer for the return value. If the value is negative, break the process and propagate the error code. This commit also fixes the uninitialized symbol 'dyn_addr', reported by Smatch static checker. Fixes: 4008a74 ("i3c: master: svc: Fix npcm845 FIFO empty issue") Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Stanley Chu <[email protected]> Reviewed-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 2a78530 commit d6cb667

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
940940
u8 *addrs, unsigned int *count)
941941
{
942942
u64 prov_id[SVC_I3C_MAX_DEVS] = {}, nacking_prov_id = 0;
943-
unsigned int dev_nb = 0, last_addr = 0, dyn_addr;
943+
unsigned int dev_nb = 0, last_addr = 0, dyn_addr = 0;
944944
u32 reg;
945945
int ret, i;
946946

@@ -998,10 +998,11 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
998998
* filling within a few hundred nanoseconds, which is significantly
999999
* faster compared to the 64 SCL clock cycles.
10001000
*/
1001-
dyn_addr = i3c_master_get_free_addr(&master->base, last_addr + 1);
1002-
if (dyn_addr < 0)
1003-
return -ENOSPC;
1001+
ret = i3c_master_get_free_addr(&master->base, last_addr + 1);
1002+
if (ret < 0)
1003+
break;
10041004

1005+
dyn_addr = ret;
10051006
writel(dyn_addr, master->regs + SVC_I3C_MWDATAB);
10061007

10071008
/*

0 commit comments

Comments
 (0)