Commit f21ae651 authored by Marek Vasut's avatar Marek Vasut

mxssb: Add section to the section list early

Add the newly allocated section into the section list very early, so that
in case of a failure during command parsing, the section can be properly
deallocated with all the other sections.
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent 32b5eff5
......@@ -796,6 +796,8 @@ static int sb_parse_sections(struct sb_image_ctx *ictx)
if (!head)
head = sctx;
if (prev)
prev->sect = sctx;
/*
* The sb_insts_pos will also be modified in sb_parse_cmds()!
......@@ -816,8 +818,6 @@ static int sb_parse_sections(struct sb_image_ctx *ictx)
ictx->section_count++;
if (prev)
prev->sect = sctx;
prev = sctx;
free(line);
}
......@@ -829,8 +829,6 @@ static int sb_parse_sections(struct sb_image_ctx *ictx)
fail:
if (line)
free(line);
if (sctx)
free(sctx);
while (head) {
sctx = head;
c_head = head->cmd;
......
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