* [PATCH] i3c: master: dw: check return of dw_i3c_master_get_free_pos()
@ 2022-01-08 15:09 trix
2022-01-13 1:07 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2022-01-08 15:09 UTC (permalink / raw)
To: vitor.soares, alexandre.belloni, nathan, ndesaulniers, bbrezillon
Cc: linux-i3c, linux-kernel, llvm, Tom Rix
From: Tom Rix <trix@redhat.com>
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>
---
drivers/i3c/master/dw-i3c-master.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 03a368da51b95..51a8608203de7 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) |
--
2.26.3
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i3c: master: dw: check return of dw_i3c_master_get_free_pos()
2022-01-08 15:09 [PATCH] i3c: master: dw: check return of dw_i3c_master_get_free_pos() trix
@ 2022-01-13 1:07 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2022-01-13 1:07 UTC (permalink / raw)
To: bbrezillon, trix, ndesaulniers, vitor.soares, nathan
Cc: Alexandre Belloni, linux-i3c, linux-kernel, llvm
On Sat, 8 Jan 2022 07:09:48 -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> 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,
--
Alexandre Belloni <alexandre.belloni@bootlin.com>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-13 1:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 15:09 [PATCH] i3c: master: dw: check return of dw_i3c_master_get_free_pos() trix
2022-01-13 1:07 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).