summaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2016-08-10 11:57:03 -0700
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-08-18 12:33:20 -0700
commit13c4245b53aca55ee523e1731c247d3d19d070fa (patch)
tree46b2781eb48afc3b92ebc0483b0537cf00cf416f /drivers/remoteproc
parent988d204cdaf604c59316dadb98eba2da2188b762 (diff)
downloadlinux-13c4245b53aca55ee523e1731c247d3d19d070fa.tar.gz
linux-13c4245b53aca55ee523e1731c247d3d19d070fa.tar.bz2
linux-13c4245b53aca55ee523e1731c247d3d19d070fa.zip
remoteproc: Only update table_ptr if we have a loaded table
In the case that we have a resource table, but not a loaded one we should leave the table_ptr intact, as subsequent resource handling could otherwise dereference the NULL pointer. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index e2c569151fe7..18f428618cf6 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -867,12 +867,15 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
* The starting device has been given the rproc->cached_table as the
* resource table. The address of the vring along with the other
* allocated resources (carveouts etc) is stored in cached_table.
- * In order to pass this information to the remote device we must
- * copy this information to device memory.
+ * In order to pass this information to the remote device we must copy
+ * this information to device memory. We also update the table_ptr so
+ * that any subsequent changes will be applied to the loaded version.
*/
loaded_table = rproc_find_loaded_rsc_table(rproc, fw);
- if (loaded_table)
+ if (loaded_table) {
memcpy(loaded_table, rproc->cached_table, tablesz);
+ rproc->table_ptr = loaded_table;
+ }
/* power up the remote processor */
ret = rproc->ops->start(rproc);
@@ -881,13 +884,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
goto clean_up;
}
- /*
- * Update table_ptr so that all subsequent vring allocations and
- * virtio fields manipulation update the actual loaded resource table
- * in device memory.
- */
- rproc->table_ptr = loaded_table;
-
rproc->state = RPROC_RUNNING;
dev_info(dev, "remote processor %s is now up\n", rproc->name);