diff mbox series

[stable,4.19,06/17] remoteproc: fix rproc_da_to_va in case of unallocated carveout

Message ID 20191128165002.6234-7-mathieu.poirier@linaro.org (mailing list archive)
State New, archived
Headers show
Series candidates for stable 4.19.y | expand

Commit Message

Mathieu Poirier Nov. 28, 2019, 4:49 p.m. UTC
From: Loic Pallardy <loic.pallardy@st.com>

commit 74457c40f97a98142bb13153395d304ad3c85cdd upstream

With introduction of rproc_alloc_registered_carveouts() which
delays carveout allocation just before the start of the remote
processor, rproc_da_to_va() could be called before all carveouts
are allocated.
This patch adds a check in rproc_da_to_va() to return NULL if
carveout is not allocated.

Fixes: d7c51706d095 ("remoteproc: add alloc ops in rproc_mem_entry struct")

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: stable <stable@vger.kernel.org> # 4.19
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Greg Kroah-Hartman Dec. 3, 2019, 7:43 p.m. UTC | #1
On Thu, Nov 28, 2019 at 09:49:51AM -0700, Mathieu Poirier wrote:
> From: Loic Pallardy <loic.pallardy@st.com>
> 
> commit 74457c40f97a98142bb13153395d304ad3c85cdd upstream
> 
> With introduction of rproc_alloc_registered_carveouts() which
> delays carveout allocation just before the start of the remote
> processor, rproc_da_to_va() could be called before all carveouts
> are allocated.
> This patch adds a check in rproc_da_to_va() to return NULL if
> carveout is not allocated.
> 
> Fixes: d7c51706d095 ("remoteproc: add alloc ops in rproc_mem_entry struct")

This commit only shows up in 4.20, not 4.19, so why is this patch
relevant for 4.19?

thanks,

greg k-h
Mathieu Poirier Dec. 4, 2019, 6:13 p.m. UTC | #2
On Tue, 3 Dec 2019 at 12:43, Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Thu, Nov 28, 2019 at 09:49:51AM -0700, Mathieu Poirier wrote:
> > From: Loic Pallardy <loic.pallardy@st.com>
> >
> > commit 74457c40f97a98142bb13153395d304ad3c85cdd upstream
> >
> > With introduction of rproc_alloc_registered_carveouts() which
> > delays carveout allocation just before the start of the remote
> > processor, rproc_da_to_va() could be called before all carveouts
> > are allocated.
> > This patch adds a check in rproc_da_to_va() to return NULL if
> > carveout is not allocated.
> >
> > Fixes: d7c51706d095 ("remoteproc: add alloc ops in rproc_mem_entry struct")
>
> This commit only shows up in 4.20, not 4.19, so why is this patch
> relevant for 4.19?

Your scripts are better than mine...

>
> thanks,
>
> greg k-h
diff mbox series

Patch

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index aa6206706fe3..af9d443e7796 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -183,6 +183,10 @@  void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
 	list_for_each_entry(carveout, &rproc->carveouts, node) {
 		int offset = da - carveout->da;
 
+		/*  Verify that carveout is allocated */
+		if (!carveout->va)
+			continue;
+
 		/* try next carveout if da is too small */
 		if (offset < 0)
 			continue;