Skip to contentSkip to conversation

i3c: master: dw: check return of dw_i3c_master_get_free_pos()

PATCH Applied [email protected] 2 participants 2 messages Jan 8, 2022 – Jan 13, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i3c: master: dw: check return of dw_i3c_master_get_free_pos()

From: Tom Rix <[email protected]>

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 1dd728f5d4d4 ("i3c: master: Add driver for Synopsys DesignWare IP")
---
 drivers/i3c/master/dw-i3c-master.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/i3c/master/dw-i3c-master.c +4 -0
index 03a368da51b95..51a8608203de7 100644
@@ -793,6 +793,10 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 		return -ENOMEM;
 
 	pos = dw_i3c_master_get_free_pos(master);
+	if (pos < 0) {
+		dw_i3c_master_free_xfer(xfer);
+		return pos;
+	}
 	cmd = &xfer->cmds[0];
 	cmd->cmd_hi = 0x1;
 	cmd->cmd_lo = COMMAND_PORT_DEV_COUNT(master->maxdevs - pos) |
Signature · 1 line
2.26.3
maintainer Applied
#1 lore raw
Quoted 9 lines · On Sat, 8 Jan 2022 07:09:48 -0800, [email protected] wrote:

From: Tom Rix <[email protected]>

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) |
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~

[...]

Applied, thanks!

[1/1] i3c: master: dw: check return of dw_i3c_master_get_free_pos()

      commit: 13462ba1815db5a96891293a9cfaa2451f7bd623

Best regards,

Signature · 1 line
Alexandre Belloni <[email protected]>