aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Rix <trix@redhat.com>2022-01-08 07:09:48 -0800
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2022-01-13 02:05:50 +0100
commit13462ba1815db5a96891293a9cfaa2451f7bd623 (patch)
treea5ed22167ccda1202bbbe7c7e3eacdc94ac7b611
parenti3c: master: mipi-i3c-hci: correct the config reference for endianness (diff)
downloadlinux-dev-13462ba1815db5a96891293a9cfaa2451f7bd623.tar.xz
linux-dev-13462ba1815db5a96891293a9cfaa2451f7bd623.zip
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: 1dd728f5d4d4 ("i3c: master: Add driver for Synopsys DesignWare IP") Signed-off-by: Tom Rix <trix@redhat.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220108150948.3988790-1-trix@redhat.com
-rw-r--r--drivers/i3c/master/dw-i3c-master.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 03a368da51b9..51a8608203de 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -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) |