remoteproc: Fix wrong rvring index computation
authorClement Leger <cleger@kalray.eu>
Fri, 4 Oct 2019 07:37:36 +0000 (09:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 2 May 2020 15:25:47 +0000 (17:25 +0200)
commit 00a0eec59ddbb1ce966b19097d8a8d2f777e726a upstream.

Index of rvring is computed using pointer arithmetic. However, since
rvring->rvdev->vring is the base of the vring array, computation
of rvring idx should be reversed. It previously lead to writing at negative
indices in the resource table.

Signed-off-by: Clement Leger <cleger@kalray.eu>
Link: https://lore.kernel.org/r/20191004073736.8327-1-cleger@kalray.eu
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Doug Anderson <dianders@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/remoteproc/remoteproc_core.c

index abbef17c97ee2a9ec44038ea94d3cf80e0febf7b..d5ff272fde34390ae3c26f716aac500c6fb3fe5a 100644 (file)
@@ -289,7 +289,7 @@ void rproc_free_vring(struct rproc_vring *rvring)
 {
        int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
        struct rproc *rproc = rvring->rvdev->rproc;
-       int idx = rvring->rvdev->vring - rvring;
+       int idx = rvring - rvring->rvdev->vring;
        struct fw_rsc_vdev *rsc;
 
        dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);