summaryrefslogtreecommitdiff
path: root/drivers/dma/qcom/gpi.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2021-01-03 16:57:29 +0300
committerVinod Koul <vkoul@kernel.org>2021-01-04 15:38:36 +0300
commit0bd1bf86ab79555425b9f0b63005e181defe4da6 (patch)
tree351085ec5a122f4fbde7a4fbc56544f5e4e993c9 /drivers/dma/qcom/gpi.c
parentcc465fa269bc0dc63a1ab7384110e4079fb40421 (diff)
downloadlinux-0bd1bf86ab79555425b9f0b63005e181defe4da6.tar.xz
dmaengine: qcom: fix gpi undefined behavior
gcc points out an incorrect error handling loop: drivers/dma/qcom/gpi.c: In function 'gpi_ch_init': drivers/dma/qcom/gpi.c:1254:15: error: iteration 2 invokes undefined behavior [-Werror=aggressive-loop-optimizations] 1254 | struct gpii *gpii = gchan->gpii; | ^~~~ drivers/dma/qcom/gpi.c:1951:2: note: within this loop 1951 | for (i = i - 1; i >= 0; i++) { | ^~~ Change the loop to correctly walk backwards through the initialized fields rather than off into the woods. Fixes: 5d0c3533a19f ("dmaengine: qcom: Add GPI dma driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20210103135738.3741123-1-arnd@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma/qcom/gpi.c')
-rw-r--r--drivers/dma/qcom/gpi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
index 556c070a514c..1a0bf6b0567a 100644
--- a/drivers/dma/qcom/gpi.c
+++ b/drivers/dma/qcom/gpi.c
@@ -1948,7 +1948,7 @@ static int gpi_ch_init(struct gchan *gchan)
return ret;
error_start_chan:
- for (i = i - 1; i >= 0; i++) {
+ for (i = i - 1; i >= 0; i--) {
gpi_stop_chan(&gpii->gchan[i]);
gpi_send_cmd(gpii, gchan, GPI_CH_CMD_RESET);
}