remoteproc: Reset table_ptr in rproc_start() failure paths
PATCH 1/1 remoteproc: Reset table_ptr in rproc_start() failure paths
Unwind the modified table_ptr and restore it to the local copy upon any subsequent failures in the rproc_start() function. This keeps the function to remain balanced on failures without the need to balance any modified variables elsewhere.
While at this, do some minor cleanup of the extra lines between the failure labels as well.
--- drivers/remoteproc/remoteproc_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/remoteproc/remoteproc_core.c +4 -3
@@ -953,7 +953,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)if (ret) {dev_err (dev,"failed to prepare subdevices for %s: %d\n" , rproc->name, ret); -return ret; + goto reset_table_ptr; }/* power up the remote processor */
@@ -979,10 +979,11 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) stop_rproc: rproc->ops->stop (rproc); - unprepare_subdevices:rproc_unprepare_subdevices (rproc); - +reset_table_ptr: +if (loaded_table) + rproc->table_ptr = rproc->cached_table;return ret; }
Signature · 1 line
2.18.0
Quoted 5 lines · Suman Anna
Unwind the modified
table_ptrand restore it to the local copy upon any subsequent failures in therproc_start()function. This keeps the function to remain balanced on failures without the need to balance any modified variables elsewhere.
Good catch.
Quoted 22 lines
While at this, do some minor cleanup of the extra lines between the failure labels as well.
Signed-off-by Suman Anna <[email protected]>--- drivers/remoteproc/remoteproc_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/remoteproc/remoteproc_core.c +1
-1@@ -953,7 +953,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)if (ret) {dev_err (dev,"failed to prepare subdevices for %s: %d\n" , rproc->name, ret); -return ret; + goto reset_table_ptr; }/* power up the remote processor */
drivers/remoteproc/remoteproc_core.c static int rproc_start(struct rproc *rproc, const struct firmware *fw) · line 985
Quoted 9 lines
drivers/remoteproc/remoteproc_core.c +2
-2@@ -979,10 +979,11 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) stop_rproc: rproc->ops->stop (rproc); - unprepare_subdevices:rproc_unprepare_subdevices (rproc); - +reset_table_ptr: +if (loaded_table)
Regardless of us having a loaded_table it should have the same value as cached_table when we return - which might be NULL if we don't have a resource table.
So I applied this without the conditional, please object if I missed something.
Regards,
Bjorn
Quoted 7 lines
drivers/remoteproc/remoteproc_core.c +1
-0+ rproc->table_ptr = rproc->cached_table;return ret; }Signature · 1 line
2.18.0
Quoted 46 lines · Bjorn Andersson
Quoted 5 lines · Suman Anna
Unwind the modified
table_ptrand restore it to the local copy upon any subsequent failures in therproc_start()function. This keeps the function to remain balanced on failures without the need to balance any modified variables elsewhere.Good catch.
Quoted 22 lines
While at this, do some minor cleanup of the extra lines between the failure labels as well.
Signed-off-by Suman Anna <[email protected]>--- drivers/remoteproc/remoteproc_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/remoteproc/remoteproc_core.c +1
-1@@ -953,7 +953,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)if (ret) {dev_err (dev,"failed to prepare subdevices for %s: %d\n" , rproc->name, ret); -return ret; + goto reset_table_ptr; }/* power up the remote processor */ drivers/remoteproc/remoteproc_core.c static int rproc_start(struct rproc *rproc, const struct firmware *fw) · line 985
Quoted 9 lines
drivers/remoteproc/remoteproc_core.c +2
-2@@ -979,10 +979,11 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) stop_rproc: rproc->ops->stop (rproc); - unprepare_subdevices:rproc_unprepare_subdevices (rproc); - +reset_table_ptr: +if (loaded_table)Regardless of us having a
loaded_tableit should have the same value ascached_tablewhen we return - which might be NULL if we don't have a resource table.
Quoted 2 lines
So I applied this without the conditional, please object if I missed something.
Yeah, that's fine. I added the conditional only to keep it symmetric, it gets modified only if loaded_table was non-NULL in the first place, and is pointing to the cached_table otherwise.
regards
Suman
Quoted 11 lines
Regards,
BjornQuoted 7 lines
drivers/remoteproc/remoteproc_core.c +1
-0+ rproc->table_ptr = rproc->cached_table;return ret; }Signature · 1 line
2.18.0