[2/7] remoteproc: fix rproc_da_to_va in case of unallocated carveout
diff mbox series

Message ID 1543526968-56091-3-git-send-email-loic.pallardy@st.com
State New, archived
Headers show
  • remoteproc: Fixes for memoy carveout management
Related show

Commit Message

Loic Pallardy Nov. 29, 2018, 9:29 p.m. UTC
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>
 drivers/remoteproc/remoteproc_core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff mbox series

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c1a66e25b173..28df71cb3fef 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -204,6 +204,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)