Skip to content

Commit f0c7938

Browse files
committed
smex: clear freed section buffer pointer on error
On a read error the section reader freed the output buffer but left the caller's pointer set, so a caller cleanup path could free it again. Clear the pointer after freeing. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent f2509c3 commit f0c7938

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

smex/elf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ int elf_read_section(const struct elf_module *module, const char *section_name,
514514

515515
error:
516516
free(*dst_buff);
517+
/* clear the caller's pointer so a caller cleanup path (e.g. ldc.c's
518+
* "if (buffer) free(buffer)") does not free the same buffer again
519+
*/
520+
*dst_buff = NULL;
517521
return ret;
518522
}
519523

0 commit comments

Comments
 (0)