Skip to content

Commit

Permalink
remoteproc: fix memory issue if load resource table failed
Browse files Browse the repository at this point in the history
Signed-off-by: chao an <anchao@xiaomi.com>
  • Loading branch information
anchao committed Mar 19, 2022
1 parent b139a1f commit 29b76a4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/remoteproc/remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,20 @@ static void *remoteproc_get_rsc_table(struct remoteproc *rproc,
if (ret < 0 || ret < (int)len || !img_data) {
metal_log(METAL_LOG_ERROR,
"get rsc failed: 0x%llx, 0x%llx\r\n", offset, len);
rsc_table = RPROC_ERR_PTR(-RPROC_EINVAL);
ret = -RPROC_EINVAL;
goto error;
}
memcpy(rsc_table, img_data, len);

ret = handle_rsc_table(rproc, rsc_table, len, NULL);
if (ret < 0) {
rsc_table = RPROC_ERR_PTR(ret);
goto error;
}
return rsc_table;

error:
metal_free_memory(rsc_table);
return rsc_table;
return RPROC_ERR_PTR(ret);
}

static int remoteproc_parse_rsc_table(struct remoteproc *rproc,
Expand Down

0 comments on commit 29b76a4

Please sign in to comment.