Skip to content

Commit 13462ba

Browse files
Tom Rixalexandrebelloni
authored andcommitted
i3c: master: dw: check return of dw_i3c_master_get_free_pos()
Clang static analysis reports this problem dw-i3c-master.c:799:9: warning: The result of the left shift is undefined because the left operand is negative COMMAND_PORT_DEV_INDEX(pos) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ pos can be negative because dw_i3c_master_get_free_pos() can return an error. So check for an error. Fixes: 1dd728f ("i3c: master: Add driver for Synopsys DesignWare IP") Signed-off-by: Tom Rix <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7a2bccd commit 13462ba

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/i3c/master/dw-i3c-master.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,10 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
793793
return -ENOMEM;
794794

795795
pos = dw_i3c_master_get_free_pos(master);
796+
if (pos < 0) {
797+
dw_i3c_master_free_xfer(xfer);
798+
return pos;
799+
}
796800
cmd = &xfer->cmds[0];
797801
cmd->cmd_hi = 0x1;
798802
cmd->cmd_lo = COMMAND_PORT_DEV_COUNT(master->maxdevs - pos) |

0 commit comments

Comments
 (0)