Commit faa463c0 authored by Marek Vasut's avatar Marek Vasut

mxssb: Load local copy of IVT

When loading the IVT, make a local copy of it instead of pointing
directly onto the static structure. This makes it easier to operate
with the file buffers associated with LOAD command in mostly uniform
manner.
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent 20ffa1a4
......@@ -589,12 +589,18 @@ static int sb_tag_to_command(struct sb_source_entry *src,
/* Load the file */
if (!strcmp(src->filename, "ivt:spl")) {
cctx->ivt = 1;
cctx->data = (uint8_t *)&sb_spl_ivt;
cctx->length = sizeof(sb_spl_ivt);
cctx->data = malloc(cctx->length);
if (!cctx->data)
return -ENOMEM;
memcpy(cctx->data, &sb_spl_ivt, cctx->length);
} else if (!strcmp(src->filename, "ivt:u-boot")) {
cctx->ivt = 1;
cctx->data = (uint8_t *)&sb_uboot_ivt;
cctx->length = sizeof(sb_uboot_ivt);
cctx->data = malloc(cctx->length);
if (!cctx->data)
return -ENOMEM;
memcpy(cctx->data, &sb_uboot_ivt, cctx->length);
} else {
ret = sb_load_file(cctx, src);
if (ret)
......@@ -891,7 +897,7 @@ static void sb_free_image(struct sb_image_ctx *ictx)
while (c_head) {
cctx = c_head;
c_head = c_head->cmd;
if (cctx->data && !cctx->ivt)
if (cctx->data)
free(cctx->data);
free(cctx);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment